// // GET: /Blog/Edit/5 public ActionResult Edit(int id) { using (var db = new BlogDataEntities()) { return View(db.Blogs.Find(id)); } }
public ActionResult Delete(int id, Blog blog) { try { using (var db = new BlogDataEntities()) { db.Entry(blog).State = System.Data.EntityState.Deleted; db.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Create(Blog blog) { try { using (var db = new BlogDataEntities()) { db.Blogs.Add(blog); db.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }
// // GET: /Blog/ public ActionResult Index() { using (var db = new BlogDataEntities()) { return View(db.Blogs.ToList()); } }