public async Task <ActionResult <int> > CreateAdminBlogPostCommentAsync(int id, [FromBody] CreateAdminCommentVm createCommentVm) { var blogPost = await _blogPostsRepository.ReadByIdAsync(id); var comment = _mapper.Map <Comment>(createCommentVm); comment.BlogPostId = blogPost.Id; await _blogPostCommentsRepository.CreateAsync(comment); return(comment.Id); }
public async Task <ActionResult <int> > CreateBlogPostCommentAsync(int id, [FromBody] CreateCommentVm createCommentVm) { var blogPost = await _blogPostsRepository.ReadByIdAsync(id); if (blogPost.Status != EnBlogPostStatus.Published) { return(BadRequest()); } var comment = _mapper.Map <Comment>(createCommentVm); comment.BlogPostId = blogPost.Id; await _blogPostCommentsRepository.CreateAsync(comment); return(comment.Id); }