From 65eeb4694e5509dae34cb15abf36464c50964e26 Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Sun, 3 Aug 2025 23:01:44 +0330 Subject: [PATCH] ... --- Hushian.Application/Services/ChatService.cs | 8 +++++--- .../Controllers/v1/ChatController.cs | 7 ++++--- Presentation/HushianWebApp/Pages/Chat.razor | 20 ++++++++++++++++++- .../Pages/FromUserSide/UserCP.razor | 19 +++++++++++++++++- .../HushianWebApp/Service/ChatService.cs | 2 ++ 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/Hushian.Application/Services/ChatService.cs b/Hushian.Application/Services/ChatService.cs index 7b5d735..350f48a 100644 --- a/Hushian.Application/Services/ChatService.cs +++ b/Hushian.Application/Services/ChatService.cs @@ -272,11 +272,12 @@ namespace Hushian.Application.Services return Response; } - public async Task FinishChat(int ChatID, int CompanyID) + public async Task FinishChat(int ChatID, int CompanyID,int? ExperID) { var convModel = await _ConversationRepository.Get() .Include(inc => inc.ConversationResponses) .FirstOrDefaultAsync(w => w.ID == ChatID && w.CompanyID==CompanyID); + if (ExperID.HasValue && !convModel.ConversationResponses.Any(a => a.ExperID == ExperID.Value)) return false; if (convModel != null && convModel.Status != ConversationStatus.Finished) { @@ -293,8 +294,9 @@ namespace Hushian.Application.Services .Include(inc => inc.ConversationResponses) .FirstOrDefaultAsync(w => w.ID == ChatID - && w.CompanyID == CompanyID - && ExperID.HasValue ? w.ConversationResponses.Any(a=>a.ExperID==ExperID.GetValueOrDefault()) :true); + && w.CompanyID == CompanyID); + + if (ExperID.HasValue && !convModel.ConversationResponses.Any(a => a.ExperID == ExperID.Value)) return false; if (convModel != null && convModel.Status == ConversationStatus.Finished) { diff --git a/Presentation/Hushian.WebApi/Controllers/v1/ChatController.cs b/Presentation/Hushian.WebApi/Controllers/v1/ChatController.cs index 66a17e9..c4dbac1 100644 --- a/Presentation/Hushian.WebApi/Controllers/v1/ChatController.cs +++ b/Presentation/Hushian.WebApi/Controllers/v1/ChatController.cs @@ -128,12 +128,13 @@ namespace Hushian.WebApi.Controllers.v1 { 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(); - int ExperID = Convert.ToInt32(strExperID); + ExperID = Convert.ToInt32(strExperID); - CompanyID = await _experService.GetCompanyIDExper(ExperID); + CompanyID = await _experService.GetCompanyIDExper(ExperID.Value); } else if (User.IsInRole("Company")) { @@ -141,7 +142,7 @@ namespace Hushian.WebApi.Controllers.v1 CompanyID = Convert.ToInt32(strCompanyID); } - return await _chatService.FinishChat(ChatID, CompanyID) ? NoContent() + return await _chatService.FinishChat(ChatID, CompanyID, ExperID) ? NoContent() : BadRequest(new List { "خطا در بروزرسانی وضعیت" }); } [HttpPut("OpenChat/{ChatID}")] diff --git a/Presentation/HushianWebApp/Pages/Chat.razor b/Presentation/HushianWebApp/Pages/Chat.razor index ad6364d..4c9c140 100644 --- a/Presentation/HushianWebApp/Pages/Chat.razor +++ b/Presentation/HushianWebApp/Pages/Chat.razor @@ -165,7 +165,7 @@ else if (ChatCurrent.status == Common.Enums.ConversationStatus.Finished && (CurrentUser.Role == "Company" || ChatCurrent.ExperID == CurrentUser.ExperID)) { - } - } @@ -488,7 +488,24 @@ background-color: #dc3545; color: white; } + /* Enhanced button styling */ + .new-conversation-btn { + border-radius: 20px; + font-weight: 600; + font-size: 0.875rem; + padding: 0.375rem 0.75rem; + transition: all 0.3s ease; + border-width: 2px; + box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2); + } + .new-conversation-btn:hover { + transform: translateY(-1px); + box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3); + border-color: #23caba; + background-color: #23caba; + color: white; + } .logout-btn { border-radius: 20px; font-weight: 600; diff --git a/Presentation/HushianWebApp/Service/ChatService.cs b/Presentation/HushianWebApp/Service/ChatService.cs index 3c34321..32ba6d0 100644 --- a/Presentation/HushianWebApp/Service/ChatService.cs +++ b/Presentation/HushianWebApp/Service/ChatService.cs @@ -62,6 +62,7 @@ namespace HushianWebApp.Service return null; } + public async Task OpenChat(int ChatID) { var response = await _baseController.Put($"{BaseRoute}OpenChat/{ChatID}"); @@ -77,6 +78,7 @@ namespace HushianWebApp.Service var response = await _baseController.Put($"{BaseRoute}ChatIsFinishFromUser/{ChatID}"); return response.IsSuccessStatusCode; } + public async Task MarkAsReadChatItemAsync(int ID) { var response = await _baseController.Put($"{BaseRoute}MarkAsReadChatItem/{ID}");