public async Task <IActionResult> AddAsync([FromBody] CreateComment newComment) { try { var commentId = await _postCommentService.AddAsync(User.GetUserId(), newComment.PostId, newComment.Content); return(Created($"comments/post/{newComment.PostId}/comment/{commentId}", null)); } catch (Exception e) { _logger.LogError($"Returning exception: {e.Message}"); return(Json(new ExceptionDto { Error = e.Message })); } }
public async Task <ActionResult> Comment(int postId, string commentBody) { await _postCommentService.AddAsync(UserHelper.UserId.Value, postId, commentBody); return(RedirectToAction(nameof(Index), "Read", new { postId = postId })); }