public async Task <IReadOnlyCollection <MatchModel> > GetAllMatches() { var players = await playersApiClient.GetAllPlayers(); var matches = await matchesApiClient.GetAllMatches(); return(MatchMapper.Map(matches, players)); }
public async Task <IReadOnlyCollection <ScoreboardItemModel> > GetScoreboardData() { var players = await playersApiClient.GetAllPlayers(); List <ScoreboardItemModel> scores = new List <ScoreboardItemModel>(); foreach (var player in players) { var matches = await this.matchesApiClient.GetPlayerMatches(player.Id); scores.Add(new ScoreboardItemModel { PlayerId = player.Id, PlayerName = player.Name, Rating = player.Rating, Wins = matches?.Where(x => x.WinnerId == player.Id)?.Count() ?? 0, Losses = matches?.Where(x => x.LoserId == player.Id)?.Count() ?? 0, }); } return(scores.OrderByDescending(x => x.Rating).ToList()); }
public async Task <IReadOnlyCollection <PlayerModel> > GetAllPlayers() { var players = await playersApiClient.GetAllPlayers(); return(PlayerMapper.Map(players)); }