public PartialViewResult RenderComments(int id) { var commentsDb = new CommentsDb(); return(PartialView("~/Views/Articles/Partials/ArticleCommentsPartial.cshtml", commentsDb.Comments.Where(x => x.ArticleId == id).ToList())); }
public async Task <ActionResult> AddComment(Comment comment) { var articlesDb = new ArticlesDb(); var article = await articlesDb.Articles.FindAsync(comment.ArticleId); var commentsDb = new CommentsDb(); comment.PublishedDate = DateTime.Now; comment.UserName = HttpContext.User.Identity.Name; commentsDb.Comments.Add(comment); await articlesDb.SaveChangesAsync(); await commentsDb.SaveChangesAsync(); return(RedirectToAction("ArticleDetail", new { articleId = article.Id })); }