...
This commit is contained in:
@@ -10,6 +10,7 @@ namespace Common.Dtos
|
||||
{
|
||||
public int CompanyID { get; set; }= 0;
|
||||
public int? ExperID { get; set; }
|
||||
public int? UserID { get; set; }
|
||||
public string Username { get; set; } = "";
|
||||
public string Role { get; set; }= "";
|
||||
}
|
||||
|
@@ -12,16 +12,18 @@ namespace Hushian.Application.Services
|
||||
public class ExperService
|
||||
{
|
||||
private readonly IGenericRepository<Company> _CompanyRepository;
|
||||
private readonly IGenericRepository<User> _UserRepository;
|
||||
private readonly IGenericRepository<Exper> _ExperRepository;
|
||||
private readonly VerificationService _VerificationService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public ExperService(IGenericRepository<Exper> experRepository, VerificationService verificationService, IMapper mapper, IGenericRepository<Company> companyRepository)
|
||||
public ExperService(IGenericRepository<Exper> experRepository, VerificationService verificationService, IMapper mapper, IGenericRepository<Company> companyRepository, IGenericRepository<User> userRepository)
|
||||
{
|
||||
_ExperRepository = experRepository;
|
||||
_VerificationService = verificationService;
|
||||
_mapper = mapper;
|
||||
_CompanyRepository = companyRepository;
|
||||
_UserRepository = userRepository;
|
||||
}
|
||||
|
||||
public async Task<ResponseBase<bool>> ADDExper(ADD_ExperDto dto, int CompanyID)
|
||||
@@ -64,7 +66,7 @@ namespace Hushian.Application.Services
|
||||
}
|
||||
public async Task<Read_ExperDto?> GetInfoExper(int ExperID)
|
||||
=> _mapper.Map<Read_ExperDto>(await _ExperRepository.Get().FirstOrDefaultAsync(w => w.ID == ExperID));
|
||||
public async Task<CurrentUserInfo?> GetCurrentUserInfo(int CompanyID, int? ExperID)
|
||||
public async Task<CurrentUserInfo?> GetCurrentUserInfo(int CompanyID, int? ExperID, int? UserID)
|
||||
{
|
||||
if (ExperID.HasValue)
|
||||
{
|
||||
@@ -76,6 +78,16 @@ namespace Hushian.Application.Services
|
||||
Role = "Exper"
|
||||
}).FirstOrDefaultAsync();
|
||||
}
|
||||
else if (UserID.HasValue)
|
||||
{
|
||||
return await _UserRepository.Get().Where(w => w.ID == UserID).Select(s => new CurrentUserInfo
|
||||
{
|
||||
CompanyID = 0,
|
||||
UserID = UserID,
|
||||
Username = s.Mobile,
|
||||
Role = "User"
|
||||
}).FirstOrDefaultAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _CompanyRepository.Get().Where(w => w.ID == CompanyID).Select(s => new CurrentUserInfo
|
||||
|
@@ -83,11 +83,12 @@ namespace Hushian.WebApi.Controllers.v1
|
||||
return response != null ? Ok(response) : BadRequest(new List<string> { "یافت نشد" });
|
||||
}
|
||||
[HttpGet("GetCurrentUserInfo")]
|
||||
[Authorize(Roles = "Exper,Company")]
|
||||
[Authorize(Roles = "Exper,Company,User")]
|
||||
public async Task<ActionResult> GetCurrentUserInfo()
|
||||
{
|
||||
int CompanyID = 0;
|
||||
int? ExperID = null;
|
||||
int? UserID = null;
|
||||
if (User.IsInRole("Exper"))
|
||||
{
|
||||
string strExperID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
||||
@@ -99,8 +100,13 @@ namespace Hushian.WebApi.Controllers.v1
|
||||
string strCompanyID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
||||
CompanyID = Convert.ToInt32(strCompanyID);
|
||||
}
|
||||
else if (User.IsInRole("User"))
|
||||
{
|
||||
string strUserID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
||||
UserID = Convert.ToInt32(strUserID);
|
||||
}
|
||||
|
||||
var response = await _experService.GetCurrentUserInfo(CompanyID,ExperID);
|
||||
var response = await _experService.GetCurrentUserInfo(CompanyID,ExperID,UserID);
|
||||
return response != null ? Ok(response) : BadRequest(new List<string> { "یافت نشد" });
|
||||
}
|
||||
[HttpPut("ExperEditingFromManager/{ExperID}")] //ویرایش کارشناس توسط مدیرش
|
||||
|
@@ -4,9 +4,13 @@
|
||||
@using Common.Dtos.Group
|
||||
@using HushianWebApp.Service
|
||||
@using HushianWebApp.Services
|
||||
@inject ChatService ChatService
|
||||
@inject ILocalStorageService localStorageService;
|
||||
@inject AuthService authService;
|
||||
@inject BaseController baseController;
|
||||
@inject CompanyService companyService
|
||||
@inject UserService userService
|
||||
@inject GroupService groupService
|
||||
@layout UserPanelLayout
|
||||
<div class="container-fluid">
|
||||
<div class="row" style="height:85vh">
|
||||
@@ -117,7 +121,7 @@
|
||||
@code {
|
||||
[Parameter] public int CompanyID { get; set; }
|
||||
|
||||
ReadANDUpdate_CompanyDto CompanyInfo = new();
|
||||
ReadANDUpdate_CompanyDto? CompanyInfo = new();
|
||||
Common.Dtos.CurrentUserInfo CurrentUser = new();
|
||||
List<Read_GroupDto> CompanyGroups = new();
|
||||
ChatItemDto? LastOpenChat = new();
|
||||
@@ -129,6 +133,7 @@
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CompanyInfo == null) return string.Empty;
|
||||
string value = $"{CompanyInfo.FullName}";
|
||||
if (LastOpenChat != null)
|
||||
{
|
||||
@@ -187,18 +192,20 @@
|
||||
async Task Afterlogin()
|
||||
{
|
||||
IsLogin = true;
|
||||
CurrentUser = new();
|
||||
CurrentUser =await userService.GetCurrentUserInfo();
|
||||
await IsCompany();
|
||||
}
|
||||
async Task IsCompany()
|
||||
{
|
||||
CompanyInfo = new();
|
||||
CompanyGroups = new();
|
||||
CompanyInfo = await companyService.GetCompany(CompanyID);
|
||||
if (CompanyInfo!=null)
|
||||
CompanyGroups = await groupService.GetGroupsCompany(CompanyID);
|
||||
await IsLastChat();
|
||||
}
|
||||
async Task IsLastChat()
|
||||
{
|
||||
LastOpenChat = null;
|
||||
if (CompanyInfo != null)
|
||||
LastOpenChat =await ChatService.GetLastChatInCompany(CompanyID);
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ namespace HushianWebApp.Service
|
||||
if (_Http.DefaultRequestHeaders.Any(t => t.Key == "Authorization"))
|
||||
_Http.DefaultRequestHeaders.Remove("Authorization");
|
||||
}
|
||||
public async Task<HttpResponseMessage> Get(string route)
|
||||
public async Task<HttpResponseMessage> Get(string route,string From="")
|
||||
{
|
||||
var result = await _Http.GetAsync(route);
|
||||
return await Check(result);
|
||||
@@ -141,7 +141,14 @@ namespace HushianWebApp.Service
|
||||
else if (result.StatusCode == System.Net.HttpStatusCode.Forbidden)
|
||||
_ToastService.Notify(new ToastMessage(ToastType.Danger, "به این بخش دسترسی ندارید"));
|
||||
else if (result.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
_ToastService.Notify(new ToastMessage(ToastType.Danger, "یافت نشد"));
|
||||
{
|
||||
string From ="" ;
|
||||
|
||||
if (result.RequestMessage.RequestUri.AbsolutePath.ToString().Contains("GetCompany")) From = "شرکت";
|
||||
|
||||
_ToastService.Notify(new ToastMessage(ToastType.Danger, $"{From} یافت نشد"));
|
||||
|
||||
}
|
||||
else if (!result.IsSuccessStatusCode)
|
||||
{
|
||||
|
||||
|
@@ -73,6 +73,9 @@ namespace HushianWebApp.Service
|
||||
return response.IsSuccessStatusCode;
|
||||
|
||||
}
|
||||
|
||||
public async Task<ChatItemDto> GetLastChatInCompany(int CompanyID)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user