コード例 #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 <IEnumerable <RetroDTO> > > Handle(GetRetrosRequest request)
        {
            var userId = this.userContextProvider.GetUserId();
            var result = await this.retroRepository.GetByUserId(userId);

            var response = result.OrderByDescending(r => r.WhenCreated)
                           .Select(r => new RetroDTO(r, userId));

            return(OperationResultCreator.Suceeded(response));
        }
コード例 #3
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())));
        }
コード例 #4
0
        public async Task <OperationResult> Handle(DeleteRetroRequest request)
        {
            var retro = await this.retroReposirotory.Get(request.RetroId);

            if (retro == null)
            {
                throw new InvalidOperationException("Retro was not found");
            }

            await this.retroReposirotory.Delete(retro);

            return(OperationResultCreator.Suceeded());
        }
コード例 #5
0
        public async Task <OperationResult <CommentDTO> > Handle(AddCommentRequest request)
        {
            var retro = await this.retroReposirotory.Get(request.RetroId);

            var activeUserId = this.userContextProvider.GetUserId();
            var comment      = new Comment(request.Comment.Text, activeUserId);

            retro.AddComment(request.GroupId, comment);

            await this.retroReposirotory.Update(retro);

            return(OperationResultCreator.Suceeded(new CommentDTO(comment, activeUserId)));
        }
コード例 #6
0
        public async Task <OperationResult <RetroDTO> > Handle(CreateRetroRequest request)
        {
            Retro newRetro;

            do
            {
                newRetro = new Retro(request.RetroName, this.userContextProvider.GetUserId());
            }while(this.retroReposirotory.GetByReference(newRetro.Reference).Result != null);

            if (request.WithDefaultGroups)
            {
                newRetro.WithDefaultGroups();
            }

            var retro = await this.retroReposirotory.Add(newRetro);

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