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))); } }
public IActionResult Details(int id) { var article = _articleData.GetArticle(id); //var comments = _commentData.GetComments(id).ToList(); //var pagedList = PagingList.Create(comments, 2, page); var model = new ArticeViewModel(); model.Id = id; model.Title = article.Title; model.Author = article.Author; model.Category = article.Category; model.Comments = _commentData.GetComments(id).ToList(); model.Date = article.Date; model.Content = article.Content; ViewData["Id"] = model.Id.ToString(); return(View(model)); }