// GET: SuperHeros/Create public IActionResult Create() { //new superhero object SuperHeros supeHero = new SuperHeros(); return(View()); }
public IActionResult Create(SuperHeros SuperHero) { try { // TODO: Add insert logic here var superHeros = db.SuperHero.Add(SuperHero); db.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Create([Bind(Include = "SuperheroName, HerosAlterEgo, PrimaryAbility, SecondaryAbility, CatchPhrase")] SuperHeros superheros) { try { SuperHerosDB.SuperHeros.Add(superheros); SuperHerosDB.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public IActionResult Edit(int id, SuperHeros superHero) { try { // TODO: Add update logic here var superHeros = db.SuperHero.Where(k => k.superHeroId == id).FirstOrDefault(); superHeros.alterEgo = superHero.alterEgo; return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public IActionResult Delete(int id, SuperHeros superHero) { try { // TODO: Add delete logic here var superHeros = db.SuperHero.Where(s => s.superHeroId == id).FirstOrDefault(); db.Remove(superHeros); db.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Delete(int id, SuperHeros superheros) { try { var hero = SuperHerosDB.SuperHeros.SingleOrDefault(h => h.SuperheroId == id); SuperHerosDB.SuperHeros.Remove(hero); SuperHerosDB.SaveChanges(); var heros = SuperHerosDB.SuperHeros.ToList(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, SuperHeros superheros) { try { var hero = SuperHerosDB.SuperHeros.SingleOrDefault(h => h.SuperheroId == id); hero.SuperheroName = superheros.SuperheroName; hero.HerosAlterEgo = superheros.HerosAlterEgo; hero.PrimaryAbility = superheros.PrimaryAbility; hero.SecondaryAbility = superheros.SecondaryAbility; hero.CatchPhrase = superheros.CatchPhrase; SuperHerosDB.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }