...
This commit is contained in:
@@ -13,6 +13,13 @@ namespace Hushian.WebApi.Controllers.v1
|
||||
public class ChatController : ControllerBase
|
||||
{
|
||||
private readonly ChatService _chatService; private readonly ExperService _experService;
|
||||
|
||||
public ChatController(ChatService chatService, ExperService experService)
|
||||
{
|
||||
_chatService = chatService;
|
||||
_experService = experService;
|
||||
}
|
||||
|
||||
[HttpPost("MyChats")]
|
||||
[Authorize(Roles = "Company,Exper")]
|
||||
public async Task<ActionResult> MyChats([FromBody] ConversationStatus status)
|
||||
@@ -100,5 +107,32 @@ namespace Hushian.WebApi.Controllers.v1
|
||||
return await _chatService.FinishChat(ChatID) ? NoContent()
|
||||
: BadRequest(new List<string> { "خطا در بروزرسانی وضعیت" });
|
||||
}
|
||||
[HttpPut("MarkAsReadChatItem/{ConversationItemID}")]
|
||||
[Authorize(Roles = "Company,User,Exper")]
|
||||
public async Task<ActionResult> MarkAsReadChatItem(int ConversationItemID)
|
||||
{
|
||||
int? ExperID = null;
|
||||
ConversationType Type = ConversationType.UE;
|
||||
if (User.IsInRole("Exper"))
|
||||
{
|
||||
string strExperID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
||||
ExperID = Convert.ToInt32(strExperID);
|
||||
Type = ConversationType.EU;
|
||||
}
|
||||
|
||||
else if (User.IsInRole("User"))
|
||||
{
|
||||
Type = ConversationType.UE;
|
||||
}
|
||||
else if (User.IsInRole("Company"))
|
||||
{
|
||||
Type = ConversationType.CU;
|
||||
}
|
||||
else return Unauthorized();
|
||||
|
||||
return await _chatService.MarkAsReadChatItem(ConversationItemID, Type, ExperID) ? NoContent()
|
||||
: BadRequest(new List<string>() { "خطا در بروزرسانی گفتگو" });
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user