This commit is contained in:
mmrbnjd
2025-07-30 23:49:51 +03:30
parent 5731c9ff97
commit 96d6f5c004
4 changed files with 58 additions and 3 deletions

View File

@@ -299,5 +299,45 @@ namespace Hushian.Application.Services
}
return false;
}
public async Task<ResponseBase<ChatItemDto>> GetLastOpenChatInCompany(int CompanyID,int UserID)
{
ResponseBase<ChatItemDto> Response = new();
Response.Value= await _ConversationRepository.Get()
.Include(inc => inc.Group)
.Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
.Where(w => w.UserID== UserID && w.Status != ConversationStatus.Finished)
.Select(s => new ChatItemDto()
{
ID = s.ID,
ExperID = s.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
ExperFullName = s.ConversationResponses.OrderBy(o => o.ID).Last().Exper.FullName,
GroupID = s.GroupID,
GroupName = s.Group.Name,
LastText = s.ConversationResponses.OrderBy(o => o.ID).Last().Text,
LastMsgdate = s.Cdatetime.GetDatePersian(),
LastMsgtime = s.Cdatetime.GetTime(),
LastMsgType = s.ConversationResponses.OrderBy(o => o.ID).Last().Type,
status = s.Status,
UserID = s.UserID,
UserFullName = string.IsNullOrEmpty(s.User.FullName) ? s.User.Mobile : s.User.FullName,
Responses = s.ConversationResponses.Select(ss => new ChatItemResponseDto()
{
ChatItemID = ss.ConversationID,
ExperID = ss.ExperID,
ExperName = ss.Exper.FullName,
FileContent = ss.FileContent,
FileName = ss.FileName,
FileType = ss.FileType,
ID = ss.ID,
IsRead = ss.IsRead,
text = ss.Text,
Type = ss.Type
}).ToList()
}).FirstOrDefaultAsync();
if (Response.Value != null) Response.Success = true;
return Response;
}
}
}