public ChampionViewModel() { var dbContext = new ApplicationDbContext(); var champions = RiotService.ChampionsService().Champions; Champions = FakeData.Get(); }
private async void BuscarPartidas() { Refresh = true; Matchs = await RiotService.FindMatchList(App.Summoner.SummonerId); Refresh = false; }
public ActionResult Index(int currentMatchId) { try { var currentModel = CurrentMatchModel; currentModel.CurrentMatchData = RiotService.MatchService(currentMatchId); CurrentMatchModel = currentModel; return(View(currentModel)); } catch (Exception e) { return(View("Error", new HandleErrorInfo(e, "Home", "Index"))); } }
/// <summary> /// Method to find a Summoner and navigate /// </summary> private async void FindSummoner() { try { App.Summoner = await RiotService.FindSummoner(SummonerName); App.NavigationService.NavigateTo("MenuMasterDetailPage", null, HistoryBehavior.Default, PresentationBehavior.Modal); } catch (Exception ex) { throw ex; } }
public CommandModule( IServiceProvider services, DiscordSocketClient client, CommandService commands, RiotService riotService, RoleService roleService, CoordinatorService coordinatorService) { this.services = services; this.client = client; this.commands = commands; this.riotService = riotService; this.roleService = roleService; this.coordinatorService = coordinatorService; }
private async Task MainAsync() { // Centralize the logic for commands into a separate method. CommandHandler commandHandler = new CommandHandler(_client, _commands, _services); await commandHandler.InstallCommandsAsync(); //Create provider if none exits if (!await DatabaseService.ProviderExistsAsync()) { await DatabaseService.PutProviderAsync(await RiotService.GetProviderAsync()); } // Login and connect. await _client.LoginAsync(TokenType.Bot, Config.DiscordToken); await _client.StartAsync(); // Wait infinitely so the bot stays connected. await Task.Delay(Timeout.Infinite); }
public ActionResult Index() { try { var model = new MatchesViewModel { ChampionData = RiotService.ChampionsService() }; using (var riotDb = new RiotDataContext()) model.Matches = riotDb.Matches.Select(x => x.MatchId).ToList(); model.CurrentMatchData = RiotService.MatchService(model.Matches.First()); model.CurrentMatchId = model.Matches.First(); CurrentMatchModel = model; return(View(model)); } catch (Exception e) { return(View("Error", new HandleErrorInfo(e, "Home", "Index"))); } }
public ActionResult Index() { try { using (var riotDb = new RiotDataContext()) { var championData = RiotService.ChampionsService(); var availableChampionIds = riotDb.Participants .Select(m => m.ChampionId ?? 0).ToList() .Where(m => m != 0).Distinct().ToList(); var availableChampions = championData.Champions .Where(x => availableChampionIds.Contains(x.Key)) .Select(x => x.Value).OrderBy(x => x.Name).ToList(); var ids = new List <int?> { availableChampions[0].Id, availableChampions[1].Id, availableChampions[2].Id }; var championTotals = new TotalsStatistics(ids, riotDb); var model = new ChampionsViewModel { AvailableChampions = availableChampions, ChampionCount = ids.Count, ChampionTotals = championTotals, ChampionIds = ids }; CurrentChampionsModel = model; return(View(model)); } } catch (Exception e) { return(View("Error", new HandleErrorInfo(e, "Champions", "Index"))); } }
private static void AddMatchData(List <Match> matches, RiotDataContext riotDb) { Console.WriteLine("Updating {0} matches.", matches.Count()); foreach (var match in matches) { var matchData = RiotService.MatchService(match.MatchId); var currentMatch = riotDb.Matches.First(m => m.MatchId == match.MatchId); currentMatch.AddMatchData(matchData); foreach (var participant in matchData.Participants) { var stats = StatisticsMapper.MapParticipantStat(participant.Statistics); currentMatch.Participants.Add(ParticipantMapper.MapParticipant(matchData, participant, stats)); } foreach (var team in matchData.Teams) { currentMatch.Teams.Add(TeamMapper.MapTeam(team)); } riotDb.SubmitChanges(); } }
public LeagueModule(RiotService riot) { _riot = riot; }
protected async override Task OnInitializedAsync() { CharacterList = await RiotService.GetValorantCharacters(); }
public SummonerController(RiotService riotService) { _riotService = riotService; }
static void Main() { Console.WriteLine("Hint: Pressing enter will use default values."); try { Console.WriteLine("How many buckets should be gather?"); RunTimes = Convert.ToInt32(Console.ReadLine()); } catch (Exception) { Console.WriteLine("Unable to read run count. Using default of 288 (24 hours)"); RunTimes = 288; } try { Console.WriteLine("What date should we start at?"); DateTime startDate; DateTime.TryParse(Console.ReadLine(), out startDate); StartDate = startDate; if (StartDate < new DateTime(2015, 4, 1)) { throw new Exception("Invalid start date"); } } catch (Exception) { Console.WriteLine("Unable to read StartDate. Using default of 4/1/2015"); StartDate = new DateTime(2015, 4, 1); } try { Console.WriteLine("How far from the start date should we offset? i*5min"); Offset = Convert.ToInt32(Console.ReadLine()); } catch (Exception) { Console.WriteLine("Unable to read offset. Using default of 0"); Offset = 0; } while (RunTimes >= 0) { Console.WriteLine("Runs remaining " + RunTimes); var bucketTime = BucketTime; Console.WriteLine("Time " + bucketTime); MatchIds = RiotService.ApiChallenge(bucketTime); if (MatchIds != null && MatchIds.Count > 0) { AddMatchIds(bucketTime); using (var riotDb = new RiotDataContext()) { var matches = riotDb.Matches.Where(m => m.MapId == null).ToList(); AddMatchData(matches, riotDb); } } else { Console.WriteLine("No matches found"); } RunTimes--; } }
public ChallengesController(ChallengeService challengeService, RiotService riotService) { _challengeService = challengeService; _riotService = riotService; }
public ActionResult Index() { try { var model = new FunStatViewModel(); using (var riotDb = new RiotDataContext()) { model.ChampionData = RiotService.ChampionsService(); model.MatchCount = riotDb.Matches.Count(); var funStats = riotDb.FunStats().ToList(); var wonMatches = riotDb.Teams.Where(x => x.Winner == true); var lostMatches = riotDb.Teams.Where(x => x.Winner == false); var matchData = wonMatches.Join(lostMatches, a => a.MatchId, b => b.MatchId, (a, b) => new MatchData(a, b)) .ToList(); model.WinData.Add(new FunStatsResponse { Name = "Baron Kills", Won = matchData.Count(x => x.WinningTeam.BaronKills > x.LosingTeam.BaronKills), Lost = matchData.Count(x => x.WinningTeam.BaronKills < x.LosingTeam.BaronKills), Tied = matchData.Count(x => x.WinningTeam.BaronKills == x.LosingTeam.BaronKills) }); model.WinData.Add(new FunStatsResponse { Name = "Dragon Kills", Won = matchData.Count(x => x.WinningTeam.DragonKills > x.LosingTeam.DragonKills), Lost = matchData.Count(x => x.WinningTeam.DragonKills < x.LosingTeam.DragonKills), Tied = matchData.Count(x => x.WinningTeam.DragonKills == x.LosingTeam.DragonKills) }); model.WinData.Add(funStats.First(x => x.Name == "Minion Kills")); model.WinData.Add(funStats.First(x => x.Name == "Kills")); model.WinData.Add(funStats.First(x => x.Name == "Wards")); model.GamesWithNoDragons = matchData.Count(x => x.WinningTeam.DragonKills == 0 && x.LosingTeam.DragonKills == 0); model.GamesWithNoBarons = matchData.Count(x => x.WinningTeam.BaronKills == 0 && x.LosingTeam.BaronKills == 0); var playedChamps = riotDb.Participants.GroupBy(x => x.ChampionId) .Select(g => new PlayedChampionData { ChampionId = g.Key ?? 0, PlayCount = g.Count() }) .OrderByDescending(x => x.PlayCount); model.MostPlayedChampions = playedChamps.Take(5).ToList(); model.LeastPlayedChampions = playedChamps.OrderBy(x => x.PlayCount).Take(5).OrderByDescending(x => x.PlayCount).ToList(); var participantsAndStats = riotDb.Participants.Join(riotDb.ParticipantStats, p => p.Id, s => s.Id, (p, s) => new { Participant = p, ParticipantStats = s }); var participantsAndStatsWinners = participantsAndStats.Where(x => x.ParticipantStats.Winner == true).GroupBy(x => x.Participant.ChampionId).Select(x => new WinRateChampionData { ChampionId = x.Key ?? 0, WinCount = x.Count() }); var participantsAndStatsLosers = participantsAndStats.Where(x => x.ParticipantStats.Winner == false).GroupBy(x => x.Participant.ChampionId).Select(x => new WinRateChampionData { ChampionId = x.Key ?? 0, LossCount = x.Count() }); model.WinRateChampionData = participantsAndStatsWinners.Join(participantsAndStatsLosers, w => w.ChampionId, l => l.ChampionId, (w, l) => new WinRateChampionData { ChampionId = w.ChampionId, WinCount = w.WinCount, LossCount = l.LossCount }) .ToList() .OrderByDescending(x => x.WinRate) .Take(5) .ToList(); return(View(model)); } } catch (Exception e) { return(View("Error", new HandleErrorInfo(e, "Home", "Index"))); } }