示例#1
0
        public async Task <IActionResult> Index(int?id)
        {
            int desiredId = id ?? 1;

            ViewData["Id"] = desiredId;
            Pokemon result = await PokeApiHelper.GetById(desiredId);

            PokdexEntryViewModel entry = PokeApiHelper.GetPokedexEntryFromPokemon(result);

            return(View(entry));
        }
示例#2
0
        public async Task <IActionResult> Index(int?id)
        {
            int desiredID = id ?? 1; // ?? null coalescing operator

            ViewData["Id"] = desiredID;

            Pokemon p = await PokeApiHelper.GetByID(desiredID);

            // TODO: Refactor property names
            PokedexEntryViewModel entry = PokeApiHelper.GetPokedexEntryFromPokemon(p);

            return(View(entry));
        }