public async Task<ObservableCollection<PokemonForm>> LoadFormsAsync(SpeciesName species, GameVersion version, int displayLanguage, CancellationToken token) { try { string query = "SELECT pf.id, pfn.name FROM pokemon_v2_pokemonform pf\n" + "LEFT JOIN pokemon_v2_pokemon p ON pf.pokemon_id = p.id\n" + "LEFT JOIN\n(SELECT e.pokemon_form_id AS id, COALESCE(o.name, e.name) AS name FROM pokemon_v2_pokemonformname e\n" + "LEFT OUTER JOIN pokemon_v2_pokemonformname o ON e.pokemon_form_id = o.pokemon_form_id and o.language_id = ?\n" + "WHERE e.language_id = 9\nGROUP BY e.pokemon_form_id)\nAS pfn ON pf.id = pfn.id\n" + "WHERE p.pokemon_species_id = ? AND pf.version_group_id <= ?"; IEnumerable<DbPokemonForm> forms = await _connection.QueryAsync<DbPokemonForm>(token, query, new object[] { displayLanguage, species.Id, version.VersionGroup }); return new ObservableCollection<PokemonForm>(forms.Select((s) => { var f = new PokemonForm { Id = s.Id }; if (String.IsNullOrWhiteSpace(s.Name)) f.Name = species.Name; else f.Name = s.Name; return f; })); } catch (Exception) { return new ObservableCollection<PokemonForm>(); } }
public Task<ObservableCollection<PokemonForm>> LoadFormsAsync(SpeciesName species, GameVersion version, int displayLanguage, CancellationToken token) { var tcs = new TaskCompletionSource<ObservableCollection<PokemonForm>>(); tcs.SetResult(new ObservableCollection<PokemonForm> { new PokemonForm { BaseExperience = 255, Height = 12, Id = 12, Name = "Mega Glurak X", Species = LoadSpeciesAsync(species.Id, version, displayLanguage, token).Result, Weight = 100 } }); return tcs.Task; }
async Task<ObservableCollection<PokemonForm>> LoadFormsAsync(SpeciesName species, GameVersion version, int language) { return await _pokemonService.LoadFormsAsync(species, version, language, _tokenSource.Token); }