public virtual ActionResult PostComment(Comment comment) { if (ModelState.IsValid) { comment.Date = DateTime.Now; db.Comments.Add(comment); db.SaveChanges(); } return PartialView("Comment", comment); }
public virtual ActionResult Create(Comment comment) { if (ModelState.IsValid) { db.Comments.Add(comment); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ArticleId = new SelectList(db.Articles, "Id", "Title", comment.ArticleId); return View(comment); }
public virtual ActionResult Edit(Comment comment) { if (ModelState.IsValid) { db.Entry(comment).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ArticleId = new SelectList(db.Articles, "Id", "Title", comment.ArticleId); return View(comment); }