Exemplo n.º 1
0
        public IActionResult Details(ArticeViewModel comment)
        {
            var userId    = _httpContext.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var articleId = HttpContext.Request.Query["id"].ToString();

            var commentToPost = new Comment();

            commentToPost.ArticleId         = comment.Id;
            commentToPost.ApplicationUserId = userId;
            commentToPost.Date    = DateTime.Now;
            commentToPost.Content = comment.CommentContent;
            if (String.IsNullOrEmpty(commentToPost.Content))
            {
                return(RedirectToAction(nameof(Details)));
            }
            else
            {
                _commentData.PostComment(commentToPost);
                return(RedirectToAction(nameof(Details)));
            }
        }