Example #1
0
        public async Task <GetUserResponse> Handle(GetUserRequest request, CancellationToken cancellationToken)
        {
            var user = await userService.GetUser(request.UserId);

            return(user != null ? new GetUserResponse {
                User = mapper.Map <UserDto>(user)
            }
                : throw new EntityNotFoundException("User not found"));
        }
Example #2
0
        public async Task <GetMessagesThreadResponse> Handle(GetMessagesThreadRequest request,
                                                             CancellationToken cancellationToken)
        {
            var messages = await messenger.GetMessagesThread(request.RecipientId, request);

            httpContextWriter.AddPagination(messages.CurrentPage, messages.PageSize, messages.TotalCount,
                                            messages.TotalPages);

            return(new GetMessagesThreadResponse
            {
                Messages = mapper.Map <List <MessageDto> >(messages),
                Recipient = mapper.Map <RecipientDto>(await userService.GetUser(request.RecipientId))
            });
        }