Пример #1
0
        //Verifica que el pokemon no exista y lo Almacena en la lista general

        public void GuardarPokemon(Pokemones Pokemones, int tipo)
        {
            switch (tipo)
            {
            case 1:
                var Busqueda = PokemonesPlanta.Where(p => p.PokeName == Pokemones.PokeName).ToList();

                //if it didnt find any coincidence, then searchresult is null
                if (Busqueda.Count() > 0)
                {
                    throw new Exception("pokemon already stored");
                }
                else
                {
                    //otherwise it stores the pokemon successfully
                    GuardarPokemones(Pokemones);
                }
                break;

            case 2:
                var Busqueda1 = PokemonesAgua.Where(p => p.PokeName == Pokemones.PokeName).ToList();

                //if it didnt find any coincidence, then searchresult is null
                if (Busqueda1.Count() > 0)
                {
                    throw new Exception("pokemon already stored");
                }
                else
                {
                    //otherwise it stores the pokemon successfully
                    GuardarPokemones(Pokemones);
                }
                break;

            //finds any coincidence in the list based on the pkm.Name

            case 3:
                var Busqueda2 = PokemonesFuego.Where(p => p.PokeName == Pokemones.PokeName).ToList();

                //if it didnt find any coincidence, then searchresult is null
                if (Busqueda2.Count() > 0)
                {
                    throw new Exception("pokemon already stored");
                }
                else
                {
                    //otherwise it stores the pokemon successfully
                    GuardarPokemones(Pokemones);
                }
                break;
            }
        }
Пример #2
0
        //Si ya existe no lo guarda al pokemon
        public void GuardarPokemon(Pokemones Pokemones, int tipo)
        {
            switch (tipo)
            {
            case 1:
                var Busqueda = PokemonesPlanta.Where(p => p.PokeName == Pokemones.PokeName).ToList();

                if (Busqueda.Count() > 0)
                {
                    throw new Exception("pokemon already stored");
                }
                else
                {
                    GuardarPokemones(Pokemones);
                }
                break;

            case 2:
                var Busqueda1 = PokemonesAgua.Where(p => p.PokeName == Pokemones.PokeName).ToList();

                if (Busqueda1.Count() > 0)
                {
                    throw new Exception("pokemon already stored");
                }
                else
                {
                    GuardarPokemones(Pokemones);
                }
                break;

            case 3:
                var Busqueda2 = PokemonesFuego.Where(p => p.PokeName == Pokemones.PokeName).ToList();

                if (Busqueda2.Count() > 0)
                {
                    throw new Exception("pokemon already stored");
                }
                else
                {
                    GuardarPokemones(Pokemones);
                }
                break;
            }
        }
Пример #3
0
        //Guarda los pokemons en la lista general

        public void GuardarPokemones(Pokemones pokemones)
        {
            Pokemones.Add(pokemones);
        }