Example #1
0
        public async Task <ActionResult> ChampionList(ChampionListQuery query)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpNotFoundResult());
            }

            var realm = await _dataDragon.GetRealm(query.Region).ConfigureAwait(false);

            var allChampionsDto = await _dataDragon.GetAllChampions(realm.Cdn, query.Language, query.Version).ConfigureAwait(false);

            var model = new ChampionListModel
            {
                Title         = "Champions",
                Subtitle      = $"showing all {allChampionsDto.Data.Count} champions",
                Champions     = _mapper.Map <IEnumerable <ChampionListItemModel> >(allChampionsDto),
                DropdownGroup = new DropdownGroupModel
                {
                    Regions   = Region.All(),
                    Languages = Language.All(),
                    Versions  = await _dataDragon.GetVersionsAsync(),
                    Selected  = query
                }
            };

            return(View(model));
        }
        public ActionResult Champions()
        {
            ChampionListModel m = new ChampionListModel();

            using (var client = new WebClient())
            {
                var json = client.DownloadString("http://ddragon.leagueoflegends.com/cdn/7.22.1/data/en_US/champion.json");
                m = JsonConvert.DeserializeObject <ChampionListModel>(json);
            }

            return(View(m));
        }
        public ActionResult Champion(string id)
        {
            ChampionListModel c = null;

            if (id == null)
            {
                return(new HttpNotFoundResult());
            }
            using (var client = new WebClient())
            {
                var json = client.DownloadString($"http://ddragon.leagueoflegends.com/cdn/7.22.1/data/en_US/champion/{id}.json");
                c = JsonConvert.DeserializeObject <ChampionListModel>(json);
            }
            return(View(c.data[id]));
        }