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);
        }
Example #2
0
 public void AddComment(Comment comment)
 {
     _ctx.Comments.Add(comment);
 }