...
This commit is contained in:
@@ -272,11 +272,44 @@ namespace Hushian.Application.Services
|
||||
|
||||
return Response;
|
||||
}
|
||||
public async Task<bool> FinishChat(int ChatID)
|
||||
public async Task<bool> FinishChat(int ChatID, int CompanyID)
|
||||
{
|
||||
var convModel = await _ConversationRepository.Get()
|
||||
.Include(inc => inc.ConversationResponses)
|
||||
.FirstOrDefaultAsync(w => w.ID == ChatID);
|
||||
.FirstOrDefaultAsync(w => w.ID == ChatID && w.CompanyID==CompanyID);
|
||||
|
||||
if (convModel != null && convModel.Status != ConversationStatus.Finished)
|
||||
{
|
||||
convModel.Status = ConversationStatus.Finished;
|
||||
convModel.FinishedDateTime = DateTime.Now;
|
||||
return await _ConversationRepository.UPDATEBool(convModel);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public async Task<bool> OpenChat(int ChatID, int CompanyID,int? ExperID)
|
||||
{
|
||||
var convModel = await _ConversationRepository.Get()
|
||||
.Include(inc => inc.ConversationResponses)
|
||||
.FirstOrDefaultAsync(w =>
|
||||
w.ID == ChatID
|
||||
&& w.CompanyID == CompanyID
|
||||
&& ExperID.HasValue ? w.ConversationResponses.Any(a=>a.ExperID==ExperID.GetValueOrDefault()) :true);
|
||||
|
||||
if (convModel != null && convModel.Status == ConversationStatus.Finished)
|
||||
{
|
||||
convModel.Status = ConversationStatus.InProgress;
|
||||
convModel.FinishedDateTime = null;
|
||||
return await _ConversationRepository.UPDATEBool(convModel);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public async Task<bool> FinishChatFromUser(int ChatID, int userID)
|
||||
{
|
||||
var convModel = await _ConversationRepository.Get()
|
||||
.Include(inc => inc.ConversationResponses)
|
||||
.FirstOrDefaultAsync(w => w.ID == ChatID && w.UserID == userID);
|
||||
|
||||
if (convModel != null && convModel.Status != ConversationStatus.Finished)
|
||||
{
|
||||
|
Reference in New Issue
Block a user