Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }