Exemple #1
0
        /// <summary>
        /// Get a pokemon by id, moves  will be sorted in
        /// alphabetical order
        /// </summary>
        /// <param name="desiredId"></param>
        /// <returns></returns>
        public static async Task <Pokemon> GetById(int desiredId)
        {
            PokiApiClient client  = new PokiApiClient();
            Pokemon       results = await client.GetPokemonById(desiredId);

            // Sort moves by name alphabetically
            results.moves.OrderBy(m => m.move.name);

            return(results);
        }
Exemple #2
0
        static async Task Main()
        {
            try
            {
                PokiApiClient client = new PokiApiClient();
                //Pokemon result = await client.GetPokemonByName("REGIGIGAS");
                Pokemon result = await client.GetPokemonById(578);

                Console.WriteLine($"Pokemon Id: {result.id} " +
                                  $"\nName: {result.Name} " +
                                  $"\nWeight: {result.Weight} " +
                                  $"\nHeight: {result.Height}");
            }
            catch (ArgumentException)
            {
                Console.WriteLine("That pokemon does not exist");
            }
            catch (HttpRequestException)
            {
                Console.WriteLine("Try again later");
            }
            Console.ReadKey();
        }