public async Task <PlayerMmrTimeline> CreateMmrTimeline(Match match, PlayerMMrChange player) { var count = await _matchRepository.CountFor(player.battleTag, null, match.gateway, match.gameMode, match.season); int pageSize = (int)count; var matches = await _matchRepository.LoadFor(player.battleTag, null, match.gateway, match.gameMode, pageSize, 0, match.season); PlayerMmrTimeline mmrTimeline = new PlayerMmrTimeline(player.battleTag, player.race, match.gateway, match.season); // Is there a better way to traverse through this? foreach (Matchup m in matches) { foreach (Team t in m.Teams) { foreach (PlayerOverviewMatches p in t.Players) { if (p.BattleTag == player.battleTag) { // Is this the correct sorting? mmrTimeline.MmrAtTimes.Add(new MmrAtTime(p.CurrentMmr, m.EndTime)); } } } } return(mmrTimeline); }
public async Task <IActionResult> GetMatchesPerPlayer( string playerId, int season, string opponentId = null, GameMode gameMode = GameMode.Undefined, GateWay gateWay = GateWay.Undefined, int offset = 0, int pageSize = 100) { if (pageSize > 100) { pageSize = 100; } var matches = await _matchRepository.LoadFor(playerId, opponentId, gateWay, gameMode, pageSize, offset, season); var count = await _matchRepository.CountFor(playerId, opponentId, gateWay, gameMode, season); return(Ok(new { matches, count })); }