public async Task <PagedResults <MessageResponse> > GetChannelMessagesAsync(MessageRequest request) { var member = await UnitOfWork.MemberRepository.GetMemberBySaasUserIdAsync(request.SaasUserId); Ensure.That(member).WithException(x => new NotFoundException(new ErrorDto(ErrorCode.NotFound, "Member does not exist."))).IsNotNull(); var lastReadMessage = await UnitOfWork.MessageRepository.GetLastReadMessageAsync(member.Id, request.ChannelId); var messages = await UnitOfWork.MessageRepository.GetAllChannelMessagesAsync(request.ChannelId); return(PageUtil.CreatePagedResults(messages, request.Page, request.PageSize, x => x.ToMessageResponse(lastReadMessage, _cloudStorageConfiguration))); }