public static PokedexEntryViewModel GetPokedexEntryFromPokemon(Pokemon result)
        {
            // Refactor property names
            var entry = new PokedexEntryViewModel()
            {
                Id              = result.Id,
                Name            = result.Name,
                Height          = result.Height.ToString(),
                Weight          = result.Weight.ToString(),
                PokedexImageUrl = result.Sprites.FrontDefault,
                MoveList        = result.moves
                                  .OrderBy(m => m.move.name)
                                  .Select(m => m.move.name)
                                  .ToArray()
            };

            // Set First letter to uppercase
            entry.Name = entry.Name.FirstCharToUpper();
            return(entry);
        }
        public static PokedexEntryViewModel GetPokedexEntryFromPokemon(Pokemon result)
        {
            var entry = new PokedexEntryViewModel()
            {
                Id              = result.Id,
                Name            = result.Name,
                Height          = result.Height.ToString(),
                Weight          = result.Weight.ToString(),
                PokedexImageUrl = result.Sprites.FrontDefault,
                MoveList        = result.moves
                                  .OrderBy(m => m.move.name)
                                  .Select(m => m.move.name)
                                  .ToArray()
                                  //MoveList = (from m in result.moves
                                  //            orderby m.move.name ascending
                                  //          select m.move.name).ToArray()
            };

            entry.Name = entry.Name.FirstCharToUpper();
            return(entry);
        }
Beispiel #3
0
        public static PokedexEntryViewModel GetPokedexEntryFromPokemon(Pokemon result)
        {
            //Create an entry object with the data pulled from result variable
            var entry = new PokedexEntryViewModel()
            {
                Id              = result.Id,
                Name            = result.Name,
                Height          = result.Height.ToString(),
                Weight          = result.Weight.ToString(),
                PokedexImageUrl = result.Sprites.FrontDefault,
                //MoveList = result.moves.OrderBy(m => m.move.name)
                //                       .Select(m => m.move.name)
                //                       .ToArray()
                MoveList = (from m in result.moves
                            orderby m.move.name ascending
                            select m.move.name).ToArray()
            };

            //entry.Name = entry.Name[0].ToString().ToUpper() + entry.Name.Substring(1); //Uppercases the first letter of name then concatenate's the rest of the name
            entry.Name = entry.Name.FirstCharToUpper(); //Using StringExtensions class that was created
            return(entry);
        }
Beispiel #4
0
        public static PokedexEntryViewModel GetPokedexEntryFromPokemon(Pokemon result)
        {
            var entry = new PokedexEntryViewModel()
            {
                Id              = result.id,
                Name            = result.name,
                Height          = result.height.ToString(),
                Weight          = result.weight.ToString(),
                PokedexImageUrl = result.sprites.front_default,
                MoveList        = result.moves
                                  .OrderBy(m => m.move.name)
                                  .Select(m => m.move.name)
                                  .ToArray() // Sorts and arranges by the Array

                                             // MoveList = (from m in result.moves
                                             //              orderBy m.move.name ascending
                                             //              select m.move.name).ToArray()
            };

            // Uppercase the first letter of each Pokedex name, didn't use the extension method
            entry.Name = entry.Name[0].ToString().ToUpper() +
                         entry.Name.Substring(1);
            return(entry);
        }
Beispiel #5
0
        public static PokedexEntryViewModel GetPokedexEntryFromPokemon(Pokemon p)
        {
            var entry = new PokedexEntryViewModel()
            {
                Id              = p.Id,
                Name            = p.Name,
                Height          = p.Height.ToString(),
                Weight          = p.Weight.ToString(),
                PokeDexImageUrl = p.Sprites.FrontDefault,

                // Method syntax using lambda expressions, query syntax below
                MoveList = p.moves.OrderBy(m => m.move.name)
                           .Select(m => m.move.name)
                           .ToArray()
                           //MoveList = (from m in p.moves
                           //            orderby m.move.name
                           //            select m.move.name).ToArray()
            };

            // Display Pokemon name in title case, ie Bulbasaur
            // First char to upper name => Name
            entry.Name = entry.Name.First().ToString().ToUpper() + entry.Name.Substring(1);
            return(entry);
        }