Example #1
0
        public async Task <Outcome <CommentResponse> > GetCommentAsync(int commentId)
        {
            var comment = await _repository.GetAsync(commentId);

            if (comment == null)
            {
                return(Outcome.Fail <CommentResponse>(Status400BadRequest, CommentNotFound));
            }

            return(Outcome.Success(CommentMappingHelper.MapToCommentResponse(comment)));
        }
Example #2
0
        public async Task <Outcome <CommentResponse> > UpdateCommentAsync(CommentUpdateRequest request)
        {
            var comment = await _repository.GetAsync(request.Id);

            if (comment == null)
            {
                return(Outcome.Fail <CommentResponse>(Status400BadRequest, UpdateFailed));
            }

            comment.Tone = request.Tone;
            await _repository.SaveAsync();

            return(Outcome.Success(CommentMappingHelper.MapToCommentResponse(comment)));
        }