static async Task UpdateChallengers() { var challengerLeague = await new LeagueApi(_dbContext) .Challenger(new ChallengerParameters { Type = GameQueueType.RANKED_SOLO_5x5 }); var challengers = challengerLeague.Entries .OrderByDescending(c => c.LeaguePoints) .Select(c => c.PlayerOrTeamName) .ToArray(); var dbSummoners = await _dbContext.Summoners.ToArrayAsync(); var remainingSummoners = new List <Summoner>(); var summonerApi = new SummonerApi(_dbContext); var summoners = await summonerApi.ByName(challengers); foreach (var summoner in summoners) { var dbSummoner = dbSummoners.SingleOrDefault(s => s.RiotId == summoner.Value.Id); if (dbSummoner == null) { _dbContext.Summoners.Add(new Summoner { Name = summoner.Value.Name, LastRevisedOn = summoner.Value.RevisionOn, RiotId = summoner.Value.Id, IsChallenger = true }); } else { remainingSummoners.Add(dbSummoner); dbSummoner.Name = summoner.Value.Name; dbSummoner.LastRevisedOn = summoner.Value.RevisionOn; dbSummoner.IsChallenger = true; } } dbSummoners.Except(remainingSummoners).ToList().ForEach(s => s.IsChallenger = false); await _dbContext.SaveChangesAsync(); Console.WriteLine("Challengers : OK"); }
private async void CurrentGameInfoPage_OnAppearing(object sender, EventArgs e) { var summoners = await SummonerApi.GetSummonersByNamesAsync(_viewModel.SummonerName); var summoner = summoners.First(); CurrentGameInfo currentGameInfo; try { currentGameInfo = await CurrentGameApi.GetSpectatorGameInfoAsync(summoner.Id); } catch (NotIngameException) { await DisplayAlert("Not in game", "This summoner is not ingame", "OK"); await Navigation.PopAsync(true); return; } _viewModel.CurrentGameInfo = currentGameInfo; }
public LeagueClientApi() { HttpClient = new LeagueHttpClient(); Assets = new AssetsApi(HttpClient); ChampSelect = new ChampSelectApi(HttpClient); Chat = new ChatApi(HttpClient); DataStore = new DataStoreApi(HttpClient); GameData = new GameDataApi(HttpClient); Inventory = new InventoryApi(HttpClient); ItemSets = new ItemSetsApi(HttpClient); Login = new LoginApi(HttpClient); Matchmaking = new MatchmakingApi(HttpClient); Missions = new MissionsApi(HttpClient); Performance = new PerformanceApi(HttpClient); Perks = new PerksApi(HttpClient); PlayerBehavior = new PlayerBehaviorApi(HttpClient); RiotClient = new RiotClientApi(HttpClient); Summoner = new SummonerApi(HttpClient); System = new SystemApi(HttpClient); }