Esempio n. 1
0
        public async Task <IActionResult> AddComment(string comment,
                                                     string postId, string postSlug)
        {
            var user = await GetLoggedInUser();

            var post = await _postRepo.GetPostById(postId);

            await _postRepo.AddComment(BlogUtils.CreateComment(user, comment, post));

            if (post.IsPublished)
            {
                return(Redirect(Url.Action("Post",
                                           new { slug = postSlug }) + CommentsSection));
            }

            return(Redirect(Url.Action("AnyPost",
                                       new { slug = postSlug }) + CommentsSection));
        }