public ActionResult Edit(Comment comment) { if (ModelState.IsValid) { db.Entry(comment).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(comment); }
public ActionResult Create(Comment comment) { if (ModelState.IsValid) { db.Comments.Add(comment); db.SaveChanges(); return RedirectToAction("Index"); } return View(comment); }
public ActionResult Comment(int id, string name, string email, string body) { Blog blog = db.Blogs.Find(id); Comment comment = new Comment(); comment.Blog = blog; comment.DateTime = DateTime.Now; comment.Name = name; comment.Email = email; comment.Body = body; db.Comments.Add(comment); db.SaveChanges(); return RedirectToAction("Details", new { id = id}); }