Пример #1
0
        public async Task <OperationResult <UpdateCommentResponse> > Handle(UpdateCommentRequest request)
        {
            var retro = await this.retroReposirotory.Get(request.RetroId);

            if (retro == null)
            {
                return(OperationResultCreator.Failed <UpdateCommentResponse>("Retro not found"));
            }

            var comment = retro.Groups
                          .SingleOrDefault(g => g.Id == request.GroupId)?
                          .Comments.SingleOrDefault(c => c.Id == request.Comment.Id);

            if (comment == null)
            {
                return(OperationResultCreator.Failed <UpdateCommentResponse>("Comment not found"));
            }

            comment.Text = request.Comment.Text;

            removedActions(request, comment);
            addActions(request, comment);

            await this.retroReposirotory.Update(retro);

            var response = new UpdateCommentResponse
            {
                Comment = new CommentDTO(comment, this.userContextProvider.GetUserId()),
                GroupId = request.GroupId,
                RetroId = request.RetroId
            };

            return(OperationResultCreator.Suceeded(response));
        }
Пример #2
0
        public async Task <OperationResult <RetroDTO> > Handle(GetRetroRequest request)
        {
            var result = await this.retroRepository.Get(request.RetroId);

            if (result == null)
            {
                return(OperationResultCreator.Failed <RetroDTO>($"Could not find a retro with the id: '{request.RetroId}'"));
            }

            return(OperationResultCreator.Suceeded(new RetroDTO(result, this.userContextProvider.GetUserId())));
        }