...
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,11 +16,12 @@ namespace Hushian.Application.Services
|
||||
private readonly VerificationService _VerificationService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public ExperService(IGenericRepository<Exper> experRepository, VerificationService verificationService, IMapper mapper)
|
||||
public ExperService(IGenericRepository<Exper> experRepository, VerificationService verificationService, IMapper mapper, IGenericRepository<Company> companyRepository)
|
||||
{
|
||||
_ExperRepository = experRepository;
|
||||
_VerificationService = verificationService;
|
||||
_mapper = mapper;
|
||||
_CompanyRepository = companyRepository;
|
||||
}
|
||||
|
||||
public async Task<ResponseBase<bool>> ADDExper(ADD_ExperDto dto, int CompanyID)
|
||||
|
Reference in New Issue
Block a user