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