Beispiel #1
0
        public IActionResult Delete(Pokedex.Models.Type type)
        {
            using (DBPokedexContext db = new DBPokedexContext())
            {
                db.Type.Remove(type);
                db.SaveChanges();

                return(RedirectToAction("Index", "Type"));
            }
        }
Beispiel #2
0
        public IActionResult Delete(Pokemon pokemon)
        {
            using (DBPokedexContext db = new DBPokedexContext())
            {
                db.Pokemon.Remove(pokemon);
                db.SaveChanges();

                return(RedirectToAction("Index", "Pokemon"));
            }
        }
Beispiel #3
0
        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());
            }
        }
Beispiel #4
0
        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());
            }
        }
Beispiel #5
0
        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());
            }
        }
Beispiel #6
0
        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());
            }
        }