public IActionResult Delete(int id) { using (DBPokedexContext db = new DBPokedexContext()) { return(View(db.Type.Find(id))); } }
public IActionResult Edit(int id) { using (DBPokedexContext db = new DBPokedexContext()) { var pokemon = db.Pokemon.Find(id); /*Cargar regiones*/ ViewBag.Regiones = db.Region.ToList(); var currentRegion = db.Region.Where(a => a.Id == pokemon.RegionFk).FirstOrDefault(); ViewBag.CurrentRegionNameId = currentRegion.Id; ViewBag.CurrentRegionName = currentRegion.Name; /*Cargar tipos*/ ViewBag.Tipos = db.Type.ToList(); var currentType = db.Type.Where(a => a.Id == pokemon.TypeFk).FirstOrDefault(); ViewBag.CurrentTypeNameId = currentType.Id; ViewBag.CurrentTypeName = currentType.Name; /*Cargar poderes*/ ViewBag.CurrentPowers = pokemon.Powers; /*Cargar nombre*/ ViewBag.CurrentName = pokemon.Name; } return(View()); }
public IActionResult Delete(int id) { using (DBPokedexContext db = new DBPokedexContext()) { return(View(db.Pokemon.Where(a => a.Id == id).Include(region => region.RegionFkNavigation ).Include(type => type.TypeFkNavigation).FirstOrDefault())); } }
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 Create() { /*cargar Regiones*/ using (DBPokedexContext db = new DBPokedexContext()) { ViewBag.Regiones = db.Region.ToList(); } /*cargar Tipos */ using (DBPokedexContext db = new DBPokedexContext()) { ViewBag.Tipos = db.Type.ToList(); } 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()); } }
public IActionResult Index() { using (DBPokedexContext db = new DBPokedexContext()) { var pokemon = db.Pokemon.Include(region => region.RegionFkNavigation).Include(type => type.TypeFkNavigation).ToList(); foreach (var item in pokemon) { switch (item.RegionFkNavigation.Name) { case "katto": item.RegionFkNavigation.color = "table-danger"; break; case "johto": item.RegionFkNavigation.color = "table-primary"; break; case "hoenn": item.RegionFkNavigation.color = "table-warning"; break; case "orre": item.RegionFkNavigation.color = "table-success"; break; case "sinnoh": item.RegionFkNavigation.color = "table-info"; break; default: item.RegionFkNavigation.color = "table-dark"; break; } } return(View(pokemon)); } }
public IActionResult Index() { using (DBPokedexContext db = new DBPokedexContext()) { var regions = db.Region.ToList(); foreach (var item in regions) { switch (item.Name) { case "kanto": item.color = "table-danger"; break; case "johto": item.color = "table-primary"; break; case "hoenn": item.color = "table-warning"; break; case "orre": item.color = "table-success"; break; case "sinnoh": item.color = "table-info"; break; default: item.color = "table-dark"; break; } } return(View(regions)); } }
public IActionResult Index() { using (DBPokedexContext db = new DBPokedexContext()) { var type = db.Type.ToList(); foreach (var item in type) { switch (item.Name) { case "normal": item.color = "#ffb74d"; break; case "fuego": item.color = "#ff6d00"; break; case "agua": item.color = "#01579b"; break; case "planta": item.color = "#00b887"; break; case "electrico": item.color = "#ffea00"; break; case "hielo": item.color = "#00e5ff"; break; case "lucha": item.color = "#d32f2f"; break; case "veneno": item.color = "#6200ea"; break; case "tierra": item.color = "#6d4c41"; break; case "volador": item.color = "#bbdefb"; break; case "psiquico": item.color = "#7e57c2"; break; case "insecto": item.color = "#9e9d24"; break; case "bicho": item.color = "#9e9d24"; break; case "roca": item.color = "grey"; break; case "fantasma": item.color = "#5e35b1"; break; case "dragon": item.color = "#2e7d32"; break; case "siniestro": item.color = "#558b2f"; break; case "acero": item.color = "#e0e0e0"; break; case "hada": item.color = "#f48fb1"; break; default: item.color = "table-dark"; break; } } return(View(type)); } }