コード例 #1
0
ファイル: HomeModel.cs プロジェクト: maxirejlis/APitems-LOL
 public static IList<int> GetAvailableChampions(string rank, string role) 
 {
     IList<AvgTimelineDto> avg;
     using (var data = new SqlData())
     {
         avg = data.GetDistinctAvgTimeline();
     }
     if (!string.IsNullOrWhiteSpace(rank) && rank != "All")
     {
         avg = avg.Where(a => a.Rank == rank).ToList();
     }
     if (!string.IsNullOrWhiteSpace(role) && role != "All") 
     {
         avg = avg.Where(a => a.Role == role).ToList();
     }
     return avg.Select(a => a.ChampionId).Distinct().ToList();
 }
コード例 #2
0
ファイル: HomeModel.cs プロジェクト: maxirejlis/APitems-LOL
 public static HomeViewModel Load()
 {
     HomeViewModel hmv = new HomeViewModel();
     hmv.Roles = LoadRoles();
     hmv.Ranks = LoadRanks();
     IList<Champion> champions;
     using (var data = new SqlData())
     {
         champions = data.GetChampions();
     }
     hmv.Champions = new List<ChampionViewModel>();
     foreach (var champion in champions)
     {
         var championVM = new ChampionViewModel();
         championVM.Id = champion.Id;
         championVM.Name = champion.Name;
         string linkName;
         if (champion.Name.Contains(" "))
             linkName = champion.Name.Replace(" ", string.Empty).Replace("'", string.Empty).Replace(".", string.Empty);
         else
             linkName = champion.Name.Replace("'", string.Empty).Replace(".", string.Empty).ToLower().FirstLetterToUpper();
         switch (linkName) {
             case "Kogmaw":
                 linkName = "KogMaw";
                 break;
             case "Reksai":
                 linkName = "RekSai";
                 break;
             case "Fiddlesticks":
                 linkName = "FiddleSticks";
                 break;
             case "Wukong":
                 linkName = "MonkeyKing";
                 break;
         }
         championVM.ImageUrl = string.Format(@"http://ddragon.leagueoflegends.com/cdn/5.16.1/img/champion/{0}.png", linkName);
         hmv.Champions.Add(championVM);
     }
     return hmv;
 }