Exemple #1
0
        public IActionResult QueryPoke(int pokeid)
        {
            var PokeInfo = new Dictionary <string, object>();

            PokeRequest.GetPokemonDataAsync(pokeid, ApiResponse =>
            {
                PokeInfo = ApiResponse;
            }
                                            ).Wait();

            Dictionary <string, object> pokecast = PokeInfo as Dictionary <string, object>;

            ViewBag.name = pokecast["name"];
            JArray types = (JArray)pokecast["types"];

            List <string> listTypes = new List <string>();

            for (int i = 0; i < types.Count; i++)
            {
                listTypes.Add((string)types[i]["type"]["name"]);
            }

            ViewBag.type = listTypes;

            JObject sprites = (JObject)pokecast["sprites"];

            ViewBag.sprite = sprites["front_default"];
            ViewBag.height = pokecast["height"];
            ViewBag.weight = pokecast["weight"];

            return(View("Index"));
        }
Exemple #2
0
        public JsonResult JQueryPoke(int pokeid)
        {
            var PokeInfo = new Dictionary <string, object>();

            PokeRequest.GetPokemonDataAsync(pokeid, ApiResponse =>
            {
                PokeInfo = ApiResponse;
            }
                                            ).Wait();

            return(Json(PokeInfo));
        }