public ActionResult Delete(int id, SuperHeroesClass superHeroes) { try { var deletedHero = context.SuperHeroes.Where(x => x.ID == id).FirstOrDefault(); context.SuperHeroes.Remove(deletedHero); context.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(SuperHeroesClass superHeroes) { try { context.SuperHeroes.Add(superHeroes); context.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, SuperHeroesClass superHeroes) { try { var heroEdit = context.SuperHeroes.Where(x => x.ID == id).FirstOrDefault(); heroEdit.ID = superHeroes.ID; heroEdit.Name = superHeroes.Name; heroEdit.PrimaryAbility = superHeroes.PrimaryAbility; heroEdit.SecondaryAbility = superHeroes.SecondaryAbility; heroEdit.CatchPhrase = superHeroes.CatchPhrase; context.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: SuperHeroes/Create public ActionResult Create() { SuperHeroesClass superHeroes = new SuperHeroesClass(); return(View(superHeroes)); }