This commit is contained in:
mmrbnjd
2025-08-03 17:22:49 +03:30
parent 381c877bc3
commit dace739e46
6 changed files with 192 additions and 23 deletions

View File

@@ -122,11 +122,60 @@ namespace Hushian.WebApi.Controllers.v1
return Response.Success ? Ok(Response.Value)
: BadRequest(Response.Errors);
}
[HttpGet("ChatIsFinish/{ChatID}")]
[HttpPut("ChatIsFinish/{ChatID}")]
[Authorize(Roles = "Company,Exper")]
public async Task<ActionResult> ChatIsFinish(int ChatID)
{
return await _chatService.FinishChat(ChatID) ? NoContent()
int CompanyID = 0;
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);
}
return await _chatService.FinishChat(ChatID, CompanyID) ? NoContent()
: BadRequest(new List<string> { "خطا در بروزرسانی وضعیت" });
}
[HttpPut("OpenChat/{ChatID}")]
[Authorize(Roles = "Company,Exper")]
public async Task<ActionResult> OpenChat(int ChatID)
{
int CompanyID = 0;
int? ExperID =null;
if (User.IsInRole("Exper"))
{
string strExperID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
ExperID = Convert.ToInt32(strExperID);
CompanyID = await _experService.GetCompanyIDExper(ExperID.GetValueOrDefault());
}
else if (User.IsInRole("Company"))
{
string strCompanyID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
CompanyID = Convert.ToInt32(strCompanyID);
}
return await _chatService.OpenChat(ChatID, CompanyID, ExperID) ? NoContent()
: BadRequest(new List<string> { "خطا در بروزرسانی وضعیت" });
}
[HttpPut("ChatIsFinishFromUser/{ChatID}")]
[Authorize(Roles = "User")]
public async Task<ActionResult> ChatIsFinishFromUser(int ChatID)
{
string strUserID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
int UserID = Convert.ToInt32(strUserID);
return await _chatService.FinishChatFromUser(ChatID, UserID) ? NoContent()
: BadRequest(new List<string> { "خطا در بروزرسانی وضعیت" });
}
[HttpPut("MarkAsReadChatItem/{ConversationItemID}")]