This commit is contained in:
mmrbnjd
2025-08-03 23:01:44 +03:30
parent dace739e46
commit 65eeb4694e
5 changed files with 48 additions and 8 deletions

View File

@@ -272,11 +272,12 @@ namespace Hushian.Application.Services
return Response; return Response;
} }
public async Task<bool> FinishChat(int ChatID, int CompanyID) public async Task<bool> FinishChat(int ChatID, int CompanyID,int? ExperID)
{ {
var convModel = await _ConversationRepository.Get() var convModel = await _ConversationRepository.Get()
.Include(inc => inc.ConversationResponses) .Include(inc => inc.ConversationResponses)
.FirstOrDefaultAsync(w => w.ID == ChatID && w.CompanyID==CompanyID); .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) if (convModel != null && convModel.Status != ConversationStatus.Finished)
{ {
@@ -293,8 +294,9 @@ namespace Hushian.Application.Services
.Include(inc => inc.ConversationResponses) .Include(inc => inc.ConversationResponses)
.FirstOrDefaultAsync(w => .FirstOrDefaultAsync(w =>
w.ID == ChatID w.ID == ChatID
&& w.CompanyID == CompanyID && w.CompanyID == CompanyID);
&& ExperID.HasValue ? w.ConversationResponses.Any(a=>a.ExperID==ExperID.GetValueOrDefault()) :true);
if (ExperID.HasValue && !convModel.ConversationResponses.Any(a => a.ExperID == ExperID.Value)) return false;
if (convModel != null && convModel.Status == ConversationStatus.Finished) if (convModel != null && convModel.Status == ConversationStatus.Finished)
{ {

View File

@@ -128,12 +128,13 @@ namespace Hushian.WebApi.Controllers.v1
{ {
int CompanyID = 0; int CompanyID = 0;
int? ExperID = null;
if (User.IsInRole("Exper")) if (User.IsInRole("Exper"))
{ {
string strExperID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First(); 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")) else if (User.IsInRole("Company"))
{ {
@@ -141,7 +142,7 @@ namespace Hushian.WebApi.Controllers.v1
CompanyID = Convert.ToInt32(strCompanyID); CompanyID = Convert.ToInt32(strCompanyID);
} }
return await _chatService.FinishChat(ChatID, CompanyID) ? NoContent() return await _chatService.FinishChat(ChatID, CompanyID, ExperID) ? NoContent()
: BadRequest(new List<string> { "خطا در بروزرسانی وضعیت" }); : BadRequest(new List<string> { "خطا در بروزرسانی وضعیت" });
} }
[HttpPut("OpenChat/{ChatID}")] [HttpPut("OpenChat/{ChatID}")]

View File

@@ -165,7 +165,7 @@
else if (ChatCurrent.status == Common.Enums.ConversationStatus.Finished else if (ChatCurrent.status == Common.Enums.ConversationStatus.Finished
&& (CurrentUser.Role == "Company" || ChatCurrent.ExperID == CurrentUser.ExperID)) && (CurrentUser.Role == "Company" || ChatCurrent.ExperID == CurrentUser.ExperID))
{ {
<Button Color="ButtonColor.Success" Size=ButtonSize.ExtraSmall Outline="true" Class="finish-conversation-btn" <Button Color="ButtonColor.Success" Size=ButtonSize.ExtraSmall Outline="true" Class="open-conversation-btn"
@onclick="OpenChat"> @onclick="OpenChat">
<Icon Name="IconName.Escape" /> باز کردن گفتگو <Icon Name="IconName.Escape" /> باز کردن گفتگو
@@ -379,6 +379,7 @@
ChatCurrent.status = Common.Enums.ConversationStatus.InProgress; ChatCurrent.status = Common.Enums.ConversationStatus.InProgress;
StateHasChanged(); StateHasChanged();
} }
else toastService.Notify(new ToastMessage(ToastType.Danger, "تغییر وضعیت گفتگو موفق نبود"));
} }
else toastService.Notify(new ToastMessage(ToastType.Danger, "دسترسی به این گفتگو ندارید")); else toastService.Notify(new ToastMessage(ToastType.Danger, "دسترسی به این گفتگو ندارید"));
@@ -1181,6 +1182,23 @@
color: white; color: white;
} }
.open-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);
}
.open-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;
}
.toexper-btn { .toexper-btn {
border-radius: 20px; border-radius: 20px;
font-weight: 600; font-weight: 600;

View File

@@ -39,7 +39,7 @@
<Icon Name="IconName.Escape" Class="me-1" /> اتمام گفتگو <Icon Name="IconName.Escape" Class="me-1" /> اتمام گفتگو
</Button> </Button>
} }
<Button Color="ButtonColor.Success" Size=ButtonSize.ExtraSmall Outline="true" @onclick="NewChat" Class="finish-conversation-btn"> <Button Color="ButtonColor.Success" Size=ButtonSize.ExtraSmall Outline="true" @onclick="NewChat" Class="new-conversation-btn">
<Icon Name="IconName.ChatDots" Class="me-1" /> گفتگو جدید <Icon Name="IconName.ChatDots" Class="me-1" /> گفتگو جدید
</Button> </Button>
} }
@@ -488,7 +488,24 @@
background-color: #dc3545; background-color: #dc3545;
color: white; 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 { .logout-btn {
border-radius: 20px; border-radius: 20px;
font-weight: 600; font-weight: 600;

View File

@@ -62,6 +62,7 @@ namespace HushianWebApp.Service
return null; return null;
} }
public async Task<bool> OpenChat(int ChatID) public async Task<bool> OpenChat(int ChatID)
{ {
var response = await _baseController.Put($"{BaseRoute}OpenChat/{ChatID}"); var response = await _baseController.Put($"{BaseRoute}OpenChat/{ChatID}");
@@ -77,6 +78,7 @@ namespace HushianWebApp.Service
var response = await _baseController.Put($"{BaseRoute}ChatIsFinishFromUser/{ChatID}"); var response = await _baseController.Put($"{BaseRoute}ChatIsFinishFromUser/{ChatID}");
return response.IsSuccessStatusCode; return response.IsSuccessStatusCode;
} }
public async Task<bool> MarkAsReadChatItemAsync(int ID) public async Task<bool> MarkAsReadChatItemAsync(int ID)
{ {
var response = await _baseController.Put($"{BaseRoute}MarkAsReadChatItem/{ID}"); var response = await _baseController.Put($"{BaseRoute}MarkAsReadChatItem/{ID}");