public ActionResult DeleteConfirmed(int id) { PokemonTierAssignment pokemonTierAssignment = db.PokemonTierAssignments.Find(id); db.PokemonTierAssignments.Remove(pokemonTierAssignment); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Id,PokemonLocalId,TierId")] PokemonTierAssignment pokemonTierAssignment) { if (ModelState.IsValid) { db.PokemonTierAssignments.Add(pokemonTierAssignment); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pokemonTierAssignment)); }
// GET: PokemonTierAssignments/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PokemonTierAssignment pokemonTierAssignment = db.PokemonTierAssignments.Find(id); if (pokemonTierAssignment == null) { return(HttpNotFound()); } return(View(pokemonTierAssignment)); }
// GET: PokemonTierAssignments/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PokemonTierAssignment pokemonTierAssignment = db.PokemonTierAssignments.Find(id); if (pokemonTierAssignment == null) { return(HttpNotFound()); } var viewModel = new PokemonTierAssignmentViewModel(); var pokemonAssignedTiers = db.PokemonTierAssignments.Select(pt => pt.PokemonLocalId).ToList(); viewModel.Name = db.PokemonLocals.Find(pokemonTierAssignment.PokemonLocalId).Name; viewModel.PokemonTierAssignment = pokemonTierAssignment; viewModel.PokemonSelectListItems = new SelectList(db.PokemonLocals.Where(p => !pokemonAssignedTiers.Any(pt => pt == p.Id)).ToList(), "Id", "Name", selectedValue: pokemonTierAssignment.PokemonLocalId); viewModel.TierSelectListItems = new SelectList(db.DraftTiers.ToList(), "Id", "Name"); return(View(viewModel)); }