Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            PokemonTierAssignment pokemonTierAssignment = db.PokemonTierAssignments.Find(id);

            db.PokemonTierAssignments.Remove(pokemonTierAssignment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        // 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));
        }
Esempio n. 4
0
        // 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));
        }