This commit is contained in:
mmrbnjd
2025-07-29 17:07:37 +03:30
parent cb8e8146b5
commit af37d0b85d
5 changed files with 158 additions and 28 deletions

View File

@@ -23,6 +23,18 @@ namespace Hushian.Application.Services
private readonly GroupService _groupService;
private readonly ExperService _experService;
private readonly IHubContext<ChatNotificationHub> _hubContext;
public ChatService(IGenericRepository<Conversation> conversationRepository, IGenericRepository<ConversationResponse> conversationResponseRepository, CompanyService companyService, UserService userService, GroupService groupService, ExperService experService, IHubContext<ChatNotificationHub> hubContext)
{
_ConversationRepository = conversationRepository;
_ConversationResponseRepository = conversationResponseRepository;
_companyService = companyService;
_userService = userService;
_groupService = groupService;
_experService = experService;
_hubContext = hubContext;
}
public async Task<List<ChatItemDto>> GeChatsByExperID(int ExperID, ConversationStatus status)
=> await _ConversationRepository.Get()
.Include(inc => inc.Group)
@@ -257,5 +269,35 @@ namespace Hushian.Application.Services
return true;
}
public async Task<bool> MarkAsReadChatItem(int ID, ConversationType Type, int? ExperID)
{
var item = await _ConversationResponseRepository.Get()
.Include(inc => inc.conversation).FirstOrDefaultAsync(w => w.ID == ID && !w.ExperID.HasValue
&& w.conversation.Status != ConversationStatus.Finished);
if (item != null)
{
if (Type != item.Type)
{
if (Type != ConversationType.UE && item.conversation.Status == ConversationStatus.Recorded)
{
item.conversation.Status = ConversationStatus.InProgress;
await _ConversationRepository.UPDATE(item.conversation);
}
if (!item.IsRead)
{
item.IsRead = true;
item.ReadDateTime = DateTime.Now;
item.ExperID = ExperID;
return (await _ConversationResponseRepository.UPDATE(item)) != null;
}
}
}
return false;
}
}
}