private void PrepareModel(ChampionsModel model, RiotDtos.Champion.ChampionListDto championListDto, RiotDtos.LolStaticData.Champion.ChampionListDto staticChampionListDto) { var ddragonKeyVersionsKey = string.Format(CacheKeys.DataDragonVersionByRegionKey, model.Region); var ddragonVersions = _memoryCache.Get(ddragonKeyVersionsKey, DateTime.UtcNow.AddDays(1), () => _riotClient.LolStaticData.GetVersionData(model.Region)); model.ChampionModels = new List <ChampionsModel.ChampionModel>(); foreach (var championDto in championListDto.Champions) { ChampionsModel.ChampionModel championModel = new ChampionsModel.ChampionModel(); var ddVersions = ddragonVersions as IList <string> ?? ddragonVersions.ToList(); PrepareDetailsModel(championModel, championDto, staticChampionListDto.Data.Values.FirstOrDefault(x => x.Id == championDto.Id), ddVersions); model.ChampionModels.Add(championModel); } }
// GET: Champions public ActionResult Index(ChampionsModel model) { var allChampionsKey = string.Format(CacheKeys.AllChampionsByRegionKey, model.Region); var allChampions = _cacheManager.Get(allChampionsKey, CacheExpiry, () => _riotClient.Champion.RetrieveAllChampions(model.Region)); var allStaticChampionsKey = string.Format(CacheKeys.AllStaticChampionsByRegionKey, model.Region); var allStaticChampions = _cacheManager.Get(allStaticChampionsKey, CacheExpiry, () => _riotClient.LolStaticData.GetChampionList(model.Region, champData: "all")); if (model.F2pOnly) { allChampions.Champions = allChampions.Champions.Where(x => x.FreeToPlay).ToList(); } //model.Region = Regions.NA; PrepareModel(model, allChampions, allStaticChampions); return(View(model)); }