GetExpersCompany
GetGroupsCompany
This commit is contained in:
@@ -67,6 +67,7 @@ namespace Hushian.Application.Services
|
||||
Role="Company",
|
||||
img=Company.logo,
|
||||
MobileOrUserName = Company.Mobile,
|
||||
CompanyId= Company.ID,
|
||||
Token = new JwtSecurityTokenHandler().WriteToken(_jwtSettings.GenerateToken(Company.Mobile, Company.ID, "Company"))
|
||||
};
|
||||
}
|
||||
|
@@ -128,14 +128,14 @@ namespace Hushian.Application.Services
|
||||
.Where(w => w.UserID == UserID && w.CompanyID==CompanyID)
|
||||
.Select(s => new Read_ConversationDto()
|
||||
{
|
||||
ExperID = s.ConversationResponses.Last().ExperID,
|
||||
ExperFullName = s.ConversationResponses.Last().Exper.FullName,
|
||||
ExperID = s.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
|
||||
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
||||
GroupID = s.GroupID,
|
||||
GroupName = s.Group.Name,
|
||||
LastText = s.ConversationResponses.Last().Text,
|
||||
LastText = s.ConversationResponses.OrderBy(o => o.ID).Last().Text,
|
||||
LastMsgdate = s.Cdatetime.GetDatePersian(),
|
||||
LastMsgtime = s.Cdatetime.GetTime(),
|
||||
LastMsgType = s.ConversationResponses.Last().Type,
|
||||
LastMsgType = s.ConversationResponses.OrderBy(o => o.ID).Last().Type,
|
||||
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
||||
status = s.Status,
|
||||
UserID = s.UserID,
|
||||
@@ -170,14 +170,14 @@ namespace Hushian.Application.Services
|
||||
.Where(w => w.ConversationResponses.Any(a => a.ExperID == ExperID) && w.Status == status)
|
||||
.Select(s => new Read_ConversationDto()
|
||||
{
|
||||
ExperID = s.ConversationResponses.Last().ExperID,
|
||||
ExperFullName = s.ConversationResponses.Last().Exper.FullName,
|
||||
ExperID = s.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
|
||||
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
||||
GroupID = s.GroupID,
|
||||
GroupName = s.Group.Name,
|
||||
LastText = s.ConversationResponses.Last().Text,
|
||||
LastText = s.ConversationResponses.OrderBy(o => o.ID).Last().Text,
|
||||
LastMsgdate = s.Cdatetime.GetDatePersian(),
|
||||
LastMsgtime = s.Cdatetime.GetTime(),
|
||||
LastMsgType = s.ConversationResponses.Last().Type,
|
||||
LastMsgType = s.ConversationResponses.OrderBy(o => o.ID).Last().Type,
|
||||
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
||||
status = s.Status,
|
||||
UserID = s.UserID,
|
||||
@@ -191,14 +191,14 @@ namespace Hushian.Application.Services
|
||||
.Where(w => w.CompanyID==CompanyID && w.Status ==status)
|
||||
.Select(s => new Read_ConversationDto()
|
||||
{
|
||||
ExperID = s.ConversationResponses.Last().ExperID,
|
||||
ExperFullName = s.ConversationResponses.Last().Exper.FullName,
|
||||
ExperID = s.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
|
||||
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
||||
GroupID = s.GroupID,
|
||||
GroupName = s.Group.Name,
|
||||
LastText = s.ConversationResponses.Last().Text,
|
||||
LastText = s.ConversationResponses.OrderBy(o => o.ID).Last().Text,
|
||||
LastMsgdate = s.Cdatetime.GetDatePersian(),
|
||||
LastMsgtime = s.Cdatetime.GetTime(),
|
||||
LastMsgType = s.ConversationResponses.Last().Type,
|
||||
LastMsgType = s.ConversationResponses.OrderBy(o => o.ID).Last().Type,
|
||||
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
||||
status = s.Status,
|
||||
UserID = s.UserID,
|
||||
@@ -212,14 +212,14 @@ namespace Hushian.Application.Services
|
||||
.Where(w => w.Status== ConversationStatus.Recorded && w.CompanyID == CompanyID)
|
||||
.Select(s => new Read_ConversationDto()
|
||||
{
|
||||
ExperID = s.ConversationResponses.Last().ExperID,
|
||||
ExperFullName = s.ConversationResponses.Last().Exper.FullName,
|
||||
ExperID = s.ConversationResponses.OrderBy(o=>o.ID).Last().ExperID,
|
||||
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
|
||||
GroupID = s.GroupID,
|
||||
GroupName = s.Group.Name,
|
||||
LastText = s.ConversationResponses.Last().Text,
|
||||
LastText = s.ConversationResponses.OrderBy(o => o.ID).Last().Text,
|
||||
LastMsgdate = s.Cdatetime.GetDatePersian(),
|
||||
LastMsgtime = s.Cdatetime.GetTime(),
|
||||
LastMsgType = s.ConversationResponses.Last().Type,
|
||||
LastMsgType = s.ConversationResponses.OrderBy(o => o.ID).Last().Type,
|
||||
NoReadCount = s.ConversationResponses.Count(c => !c.IsRead),
|
||||
status = s.Status,
|
||||
UserID = s.UserID,
|
||||
|
@@ -33,11 +33,30 @@ namespace Hushian.WebApi.Controllers.v1
|
||||
return response.Success ? NoContent()
|
||||
: BadRequest(response.Errors);
|
||||
}
|
||||
[HttpGet("GetExpersCompany/{CompanyID}")]
|
||||
[HttpGet("GetExpersCompany")]
|
||||
[Authorize]
|
||||
public async Task<ActionResult> GetExpersCompany(int CompanyID, int PageIndex = 1, int PageSize = 10)
|
||||
public async Task<ActionResult> GetExpersCompany(int? CompanyID)
|
||||
{
|
||||
var response = await _experService.GetExpersInCompany(CompanyID);
|
||||
if (!CompanyID.HasValue)
|
||||
{
|
||||
if (!CompanyID.HasValue)
|
||||
{
|
||||
if (User.IsInRole("Exper"))
|
||||
{
|
||||
string strExperID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
||||
int ExperID = Convert.ToInt32(strExperID);
|
||||
CompanyID = await _experService.GetCompanyIDExper(ExperID);
|
||||
}
|
||||
else if (User.IsInRole("Company"))
|
||||
{
|
||||
string strCompanyID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
||||
CompanyID = Convert.ToInt32(strCompanyID);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
var response = await _experService.GetExpersInCompany(CompanyID.GetValueOrDefault());
|
||||
return Ok(response);
|
||||
|
||||
}
|
||||
|
@@ -12,11 +12,11 @@ namespace Hushian.WebApi.Controllers.v1
|
||||
public class GroupController : ControllerBase
|
||||
{
|
||||
private readonly GroupService _groupService;
|
||||
private readonly CompanyService _companyService;
|
||||
public GroupController(GroupService groupService, CompanyService companyService)
|
||||
private readonly ExperService _experService;
|
||||
public GroupController(GroupService groupService, ExperService experService)
|
||||
{
|
||||
_groupService = groupService;
|
||||
_companyService = companyService;
|
||||
_experService = experService;
|
||||
}
|
||||
|
||||
[HttpPost("AddGroup")]
|
||||
@@ -76,8 +76,19 @@ namespace Hushian.WebApi.Controllers.v1
|
||||
|
||||
if (!CompanyID.HasValue)
|
||||
{
|
||||
string strCompanyID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
||||
CompanyID = Convert.ToInt32(strCompanyID);
|
||||
if (User.IsInRole("Exper"))
|
||||
{
|
||||
string strExperID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
||||
int ExperID = Convert.ToInt32(strExperID);
|
||||
CompanyID =await _experService.GetCompanyIDExper(ExperID);
|
||||
}
|
||||
else if (User.IsInRole("Company"))
|
||||
{
|
||||
string strCompanyID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
||||
CompanyID = Convert.ToInt32(strCompanyID);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
var response = await _groupService.GetGroupsCompany(CompanyID.Value);
|
||||
return Ok(response);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
@using HushianWebApp.Service
|
||||
@inject GroupService groupService;
|
||||
@inject UserService userService;
|
||||
@inject HushianWebApp.Services.ILocalStorageService localStorageService;
|
||||
@if (!Spinnervisible)
|
||||
{
|
||||
<div class="row">
|
||||
@@ -52,7 +53,7 @@
|
||||
@functions {
|
||||
private async Task<AutoCompleteDataProviderResult<Read_ExperDto>> DataProvider(AutoCompleteDataProviderRequest<Read_ExperDto> request)
|
||||
{
|
||||
CoExpers = await userService.GetExpersCompany(0, 0, 0);
|
||||
CoExpers = await userService.GetExpersCompany();
|
||||
return await Task.FromResult(new AutoCompleteDataProviderResult<Read_ExperDto> { Data = CoExpers.Where(w => w.FullName.Contains(request.Filter.Value)), TotalCount = CoExpers.Count() });
|
||||
}
|
||||
|
||||
|
@@ -76,7 +76,7 @@
|
||||
public string Username { get; set; }
|
||||
public string Fullname { get; set; }
|
||||
public byte[]? img { get; set; }
|
||||
public List<string> Roles { get; set; } = new();
|
||||
public string Role { get; set; }
|
||||
bool isonline = false;
|
||||
bool isAuthorizedCompanyUser = false;
|
||||
public string TitleRole { get; set; } = "";
|
||||
@@ -93,9 +93,9 @@
|
||||
}
|
||||
|
||||
|
||||
TitleRole = Roles.Any(a => a == "Company") ? "مدیر" : "کارشناس";
|
||||
TitleRole = Role == "Company" ? "مدیر" : "کارشناس";
|
||||
|
||||
isAuthorizedCompanyUser = Roles.Contains("Company") || (Roles.Contains("Exper") && await userService.CheckAvailableExperInCompany());
|
||||
isAuthorizedCompanyUser = Role=="Company" || Role=="Exper" && await userService.CheckAvailableExperInCompany();
|
||||
|
||||
string route = NavigationManager.Uri.Replace(NavigationManager.BaseUri, "").ToLower();
|
||||
if (route.Length > 0)
|
||||
@@ -170,7 +170,7 @@
|
||||
|
||||
async Task CheckOnline()
|
||||
{
|
||||
var token = await localStorageService.GetItem<string>("key");
|
||||
var token = await localStorageService.GetItem<string>("C/key");
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
isonline = false;
|
||||
@@ -188,8 +188,8 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
Roles = await localStorageService.GetItem<List<string>>("Role");
|
||||
if (Roles.Count == 1 && Roles.Contains("HushianUserCompany"))
|
||||
Role = await localStorageService.GetItem<string>("C/Role");
|
||||
if (Role=="User")
|
||||
{
|
||||
isonline = false;
|
||||
NavigationManager.NavigateTo("/NotFound");
|
||||
|
@@ -82,7 +82,7 @@
|
||||
{
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack));
|
||||
|
||||
if (!(await localStorageService.GetItem<List<string>>("Role")).Any(a => a == "HushianManagerCompany"))
|
||||
if (await localStorageService.GetItem<string>("C/Role") != "Company")
|
||||
navigationManager.NavigateTo("/NotFound");
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ AllowRowClick=true>
|
||||
@context.FullName
|
||||
</GridColumn>
|
||||
|
||||
|
||||
|
||||
|
||||
<GridColumn HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center" TItem="Read_ExperDto" HeaderText="وضعیت">
|
||||
<Switch Value="@context.Available" ValueExpression="() => context.Available" ValueChanged="async(v)=>await SwitchChanged(context,v)" />
|
||||
@@ -55,20 +55,25 @@ AllowRowClick=true>
|
||||
|
||||
Dictionary<string, object> parameters = new Dictionary<string, object>();
|
||||
Grid<Read_ExperDto> grid = default!;
|
||||
public List<Read_ExperDto> list = new();
|
||||
private Modal modal = default!;
|
||||
string title = "کارشناس جدید";
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create(this, CallBack));
|
||||
|
||||
if (await localStorageService.GetItem<string>("Role")!= "Company" )
|
||||
if (await localStorageService.GetItem<string>("C/Role")!= "Company" )
|
||||
navigationManager.NavigateTo("/NotFound");
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
private async Task<GridDataProviderResult<Read_ExperDto>> DataProvider(GridDataProviderRequest<Read_ExperDto> request)
|
||||
{
|
||||
var employees = await userService.GetExpersCompany(0, request.PageNumber, request.PageSize);
|
||||
return await Task.FromResult(request.ApplyTo(employees != null ? employees : new()));
|
||||
if (list.Count <= 0)
|
||||
list = await userService.GetExpersCompany();
|
||||
|
||||
int skip = (request.PageNumber - 1) * request.PageSize;
|
||||
|
||||
return await Task.FromResult(request.ApplyTo(list != null ? list.Skip(skip).Take(request.PageSize).ToList() : new()));
|
||||
}
|
||||
async Task CallBack()
|
||||
{
|
||||
|
@@ -18,10 +18,10 @@ namespace HushianWebApp.Service
|
||||
var response = await _baseController.Post($"{BaseRoute}AddExper", request);
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
public async Task<List<Read_ExperDto>?> GetExpersCompany(int CompanyID, int PageIndex = 1, int PageSize = 10)
|
||||
public async Task<List<Read_ExperDto>?> GetExpersCompany()
|
||||
{
|
||||
string route = $"{BaseRoute}GetExpersCompany/{CompanyID}&PageIndex={PageIndex}&PageSize={PageSize}";
|
||||
|
||||
string route = $"{BaseRoute}GetExpersCompany";
|
||||
//&PageIndex={PageIndex}&PageSize={PageSize}
|
||||
var response = await _baseController.Get(route);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
@@ -29,7 +29,17 @@ namespace HushianWebApp.Service
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task<List<Read_ExperDto>?> GetExpersCompany(int CompanyID)
|
||||
{
|
||||
string route = $"{BaseRoute}GetExpersCompany?CompanyID={CompanyID}";
|
||||
var response = await _baseController.Get(route);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return await response.Content.ReadFromJsonAsync<List<Read_ExperDto>>();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
public async Task<bool> EditUserYourself(Update_ExperDto request) //ویرایش کاربران توسط خود
|
||||
{
|
||||
|
Reference in New Issue
Block a user