public ActionResult Index(Comment comment) { if (ModelState.IsValid) { comment.CreatedOn = DateTime.Now; _db.AddComment(comment); _db.Save(); return RedirectToAction("Index"); } // error return view var vm = new CommentsVM(); vm.Comment = comment; vm.Comments = _db.GetComments(); return View("Index", vm); }
public void AddComment(Comment comment) { _ctx.Comments.Add(comment); }