public MatchResponse Create(Match match) { if(match == null) throw new ArgumentNullException("match"); return new MatchResponse( number: match.Number, gamesPlayed: match.Games.Count, players: match .Players .OrderBy(player => player.Name) .Select(player => PlayerMatchStatsResponseProvider.Create(player, match)) .ToArray() ); }
public PlayerMatchStatsResponse Create(Player player, Match match) { if(player == null) throw new ArgumentNullException("player"); if(match == null) throw new ArgumentNullException("match"); return new PlayerMatchStatsResponse( name: player.Name, dropped: player.Dropped, wins: match.Games.Where(game => game.Winner == player).Count(), losses: match.Games.Where(game => game.Winner != player && game.Winner != null).Count(), draws: match.Games.Where(game => game.Winner == null).Count() ); }