コード例 #1
0
        public async Task <CommentDTO> CreateCommentAsync(UpdateCommentRequest createdComment)
        {
            var dbComment = mapper.Map <Comment>(createdComment);

            await commentRepository.CreateCommentAsync(dbComment);

            return(mapper.Map <CommentDTO>(dbComment));
        }
コード例 #2
0
        public async Task <CommentDTO> UpdateCommentAsync(int commentId, UpdateCommentRequest updatedComment)
        {
            var dbComment = await commentRepository.GetCommentAsync(commentId);

            if (dbComment == null)
            {
                return(null);
            }

            mapper.Map(updatedComment, dbComment);

            await commentRepository.UpdateCommentAsync(dbComment);

            return(mapper.Map <CommentDTO>(dbComment));
        }