public ActionResult DeleteConfirmed(int id) { Tbhero heroes = db.Tbheroes.Find(id); db.Tbheroes.Remove(heroes); db.SaveChanges(); return(RedirectToAction("ListAll")); }
public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Service,Description,Picture")] Tbhero heroes) { if (ModelState.IsValid) { db.Entry(heroes).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ListAll")); } return(View(heroes)); }
// GET: AllHeroes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tbhero heroes = db.Tbheroes.Find(id); if (heroes == null) { return(HttpNotFound()); } return(View(heroes)); }
public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Service,Description,Picture")] Tbhero heroes) { if (heroes.Picture == null) { heroes.Picture = "http://www.flags.net/images/largeflags/POLA0001.GIF"; } try { if (ModelState.IsValid) { db.Tbheroes.Add(heroes); db.SaveChanges(); return(RedirectToAction("ListAll")); } } catch (DataException) { ModelState.AddModelError("", "Unable to save changes. Try again."); } return(View(heroes)); }