public ActionResult DeleteConfirmed(int id) { PostToCategory postToCategory = db.PostToCategories.Find(id); db.PostToCategories.Remove(postToCategory); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "PostID,CategoryName")] PostToCategory postToCategory) { if (ModelState.IsValid) { db.Entry(postToCategory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryName = new SelectList(db.Categories, "Name", "Name", postToCategory.CategoryName); ViewBag.PostID = new SelectList(db.Posts, "PostID", "Title", postToCategory.PostID); return(View(postToCategory)); }
// GET: PostToCategories/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PostToCategory postToCategory = db.PostToCategories.Find(id); if (postToCategory == null) { return(HttpNotFound()); } return(View(postToCategory)); }
// GET: PostToCategories/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PostToCategory postToCategory = db.PostToCategories.Find(id); if (postToCategory == null) { return(HttpNotFound()); } ViewBag.CategoryName = new SelectList(db.Categories, "Name", "Name", postToCategory.CategoryName); ViewBag.PostID = new SelectList(db.Posts, "PostID", "Title", postToCategory.PostID); return(View(postToCategory)); }