コード例 #1
0
        public async Task <IActionResult> Create([FromBody] CreateCommentRequest commentRequest, [FromRoute] Guid postId)
        {
            var comment = new Comment
            {
                CommentText = commentRequest.CommentText,
                PostId      = postId,
                UserId      = HttpContext.GetUserId()
            };
            await _commentService.CreateCommentAsync(comment);

            var locationUrl = _uriService.GetCommentById(comment.Id.ToString());

            comment.User = await _userManager.FindByIdAsync(comment.UserId);

            return(Created(locationUrl, new Response <CommentResponse>(_mapper.Map <CommentResponse>(comment))));
        }