public ActionResult Comment(Comment comment) { var comments = Session["comments"] as List<Comment>; if (comments == null) { comments = new List<Comment>(); } comments.Add(comment); Session["comments"] = comments; return RedirectToAction("Comments"); }
public ActionResult AddComment(Comment newComment) { var post = db.Posts.Find( newComment.PostID ); if (ModelState.IsValid) { newComment.Created = System.DateTimeOffset.Now; newComment.AuthorId = User.Identity.GetUserId(); db.Comments.Add(newComment); db.SaveChanges(); } return RedirectToAction("Details", "BlogPosts", new { Slug = post.Slug}); }