GetExpersCompany

GetGroupsCompany
This commit is contained in:
mmrbnjd
2025-07-25 21:29:57 +03:30
parent d4c4bb2ffd
commit 29107ce9c6
10 changed files with 88 additions and 42 deletions

View File

@@ -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);
}

View File

@@ -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);