generated from admin/template
33 lines
831 B
C#
33 lines
831 B
C#
using PokedexApi.Models;
|
|
|
|
namespace PokedexApi.Storage;
|
|
|
|
public class PokemonStorage
|
|
{
|
|
private List<Pokemon> _pokemons = new List<Pokemon>
|
|
{
|
|
new Pokemon(1, "Pikachu", "Electric", 12),
|
|
new Pokemon(2, "Charmander", "Fire", 8),
|
|
new Pokemon(3, "Squirtle", "Water", 10)
|
|
};
|
|
|
|
public List<Pokemon> GetAll()
|
|
{
|
|
return new List<Pokemon>(_pokemons);
|
|
}
|
|
|
|
public Pokemon? GetById(int id)
|
|
{
|
|
return _pokemons.FirstOrDefault(p => p.Id == id);
|
|
}
|
|
|
|
public List<Pokemon> Filter(string? type, int? level)
|
|
{
|
|
return _pokemons.Where(p => p.Type == type || p.Level == level).ToList();
|
|
}
|
|
public List<Pokemon> SearchByName(string query)
|
|
{
|
|
return _pokemons.Where(p => p.Name.Contains(query)).ToList();
|
|
}
|
|
public Pokemon Add(PokedexInput)
|
|
} |