public ActionResult Index() { var vm = new CommentsVM(); vm.Comments = _db.GetComments(); vm.Comment = new Comment(); return View(vm); }
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); }