public async Task <PagedItemResultDto <GetPrivateChatMessageDto> > GetMessagesAsync(GetPagedMessagesQueryDto queryDto, CancellationToken ct = default) { _logger.LogInformation("Get private chat messages {ChatId}", queryDto.ChatId); GetPagedMessagesQuery query = _mapper.Map <GetPagedMessagesQuery>(queryDto); PagedItemResultModel <PrivateChatMessage> result = await _unitOfWork.PrivateChatMessageRepository.GetMessagesAsync(query, ct); IImmutableList <GetPrivateChatMessageDto> list = _mapper.Map <ICollection <GetPrivateChatMessageDto> >(result.Items).ToImmutableList(); return(new PagedItemResultDto <GetPrivateChatMessageDto>(list, result.TotalCount)); }
public async Task <PagedItemResultDto <GetGroupChatMessageDto> > GetMessagesAsync(GetPagedMessagesQueryDto queryDto, CancellationToken ct = default) { _logger.LogInformation("Get group chat messages {ChatId}", queryDto.ChatId); GetPagedMessagesQuery query = _mapper.Map <GetPagedMessagesQuery>(queryDto); PagedItemResultModel <GroupChatMessage> result = await _unitOfWork.GroupChatMessageRepository.GetMessagesAsync(query, ct); return(_mapper.Map <PagedItemResultDto <GetGroupChatMessageDto> >(result)); }
public async Task <IActionResult> GetUserChatsAsync([FromQuery] GetPagedMessagesQueryDto query) { var messages = await _privateChatMessageService.GetMessagesAsync(query); return(Ok(messages)); }