public IActionResult Delete(Pokedex.Models.Type type) { using (DBPokedexContext db = new DBPokedexContext()) { db.Type.Remove(type); db.SaveChanges(); return(RedirectToAction("Index", "Type")); } }
public IActionResult Delete(Pokemon pokemon) { using (DBPokedexContext db = new DBPokedexContext()) { db.Pokemon.Remove(pokemon); db.SaveChanges(); return(RedirectToAction("Index", "Pokemon")); } }
public IActionResult Edit(Pokedex.Models.Type type) { if (ModelState.IsValid) { using (DBPokedexContext db = new DBPokedexContext()) { Pokedex.Models.Type Type2 = db.Type.Find(type.Id); Type2.Name = type.Name.ToLower(); db.SaveChanges(); return(RedirectToAction("Index", "Type")); } } else { return(View()); } }
public IActionResult Create(Pokemon pokemon) { if (ModelState.IsValid) { using (DBPokedexContext db = new DBPokedexContext()) { pokemon.Name = pokemon.Name.ToLower(); db.Pokemon.Add(pokemon); db.SaveChanges(); return(RedirectToAction("Index", "Pokemon")); } } else { return(View()); } }
public IActionResult Edit(Region region) { if (ModelState.IsValid) { using (DBPokedexContext db = new DBPokedexContext()) { Region region1 = db.Region.Find(region.Id); region1.Name = region.Name.ToLower(); db.SaveChanges(); return(RedirectToAction("Index", "Region")); } } else { return(View()); } }
public IActionResult Edit(Pokemon pokemon) { if (ModelState.IsValid) { using (DBPokedexContext db = new DBPokedexContext()) { Pokemon pokemon1 = db.Pokemon.Find(pokemon.Id); pokemon1.Name = pokemon.Name.ToLower(); pokemon1.RegionFk = pokemon.RegionFk; pokemon1.TypeFk = pokemon.TypeFk; pokemon1.Powers = pokemon.Powers; db.SaveChanges(); return(RedirectToAction("Index", "Pokemon")); } } else { return(View()); } }