public void CatchPokemon(Pokemon pokemon)//boolean of pokemon returnen of het gelukt is. { if (Pokemons.Count() < 6) { Pokemons.Add(pokemon); } else { } }
public async Task GetPokemons() { var response = await httpClient.GetAsync(""); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); var pokemons = JsonSerializer.Deserialize<Pokemons>(responseBody).Results; foreach (var pokemon in pokemons) { var cur = await httpClient.GetAsync(pokemon.Url); var body = await cur.Content.ReadAsStringAsync(); var curdetails = JsonSerializer.Deserialize<Data.Pokemon>(body); Pokemons.Add(curdetails); } Message = "Received " + Pokemons.Count() + " pokemons!"; }