public ScoreViewModel(IMatchService matchService,
                              IPlayerInningService playerInningService,
                              string matchId, string teamId, bool IsBatsman)
        {
            _matchService        = matchService ?? throw new ArgumentNullException($"MatchService is null");
            _playerInningService = playerInningService ?? throw new ArgumentNullException($"PlayerInningService is null");

            CurrentMatch = _matchService.GetMatch(matchId);
            IList <PlayerInning> batsman;
            IList <PlayerInning> bowler;

            if ((IsBatsman && CurrentMatch.HomeTeam.Id == teamId) || (!IsBatsman && CurrentMatch.AwayTeam.Id == teamId))
            {
                BattingTeamName = CurrentMatch.HomeTeam.TeamName;
                batsman         = _playerInningService.GetAllPlayerInningsByTeamMatchId(CurrentMatch.HomeTeam.Id, matchId);
                bowler          = _playerInningService.GetAllPlayerInningsByTeamMatchId(CurrentMatch.AwayTeam.Id, matchId);
            }
            else if ((IsBatsman && CurrentMatch.AwayTeam.Id == teamId) || (!IsBatsman && CurrentMatch.HomeTeam.Id == teamId))
            {
                BattingTeamName = CurrentMatch.AwayTeam.TeamName;
                batsman         = _playerInningService.GetAllPlayerInningsByTeamMatchId(CurrentMatch.AwayTeam.Id, matchId);
                bowler          = _playerInningService.GetAllPlayerInningsByTeamMatchId(CurrentMatch.HomeTeam.Id, matchId);
            }
            else
            {
                throw new ArgumentException("Team Id is invalid");
            }

            ActiveBatsman  = batsman.Where(p => p.HowOut == "not out").ToList();
            ActiveBowler   = bowler.ToList();
            Fielder_Keeper = bowler.ToList();
        }
        public MatchDetailViewModel(IMatchService matchService, IPlayerInningService playerInningService,
                                    string matchId, string battingInningId)
        {
            _matchService        = matchService ?? throw new ArgumentNullException($"MatchService is null");
            _playerInningService = playerInningService ?? throw new ArgumentNullException($"PlayerInningService is null");
            Match = _matchService.GetMatch(matchId);

            SelectedInnings(battingInningId);
        }
Ejemplo n.º 3
0
        public AddMatchViewModel(IMatchService matchService,
                                 ITeamService teamService,
                                 IPlayerInningService playerInningService,
                                 IUmpireService umpireService)
        {
            _matchService        = matchService ?? throw new ArgumentNullException($"MatchService is null");
            _teamService         = teamService ?? throw new ArgumentNullException($"TeamService is null");
            _playerInningService = playerInningService ?? throw new ArgumentNullException($"PlayerInningService is null");
            _umpireService       = umpireService ?? throw new ArgumentNullException($"PlayerInningService is null");

            Teams   = _teamService.GetTeams().ToList();
            Matches = _matchService.GetMatches().ToList();
            var UmpiresListWithDupes = _umpireService.GetUmpires().ToList();

            Umpires = UmpiresListWithDupes.Distinct().ToList();
        }
Ejemplo n.º 4
0
        public StatisticsViewModel(ITeamService teamService,
                                   IPlayerInningService playerInningService,
                                   StatisticsService statistics)
        {
            _teamService = teamService ??
                           throw new ArgumentNullException($"TeamService is null");
            _playerInningService = playerInningService ??
                                   throw new ArgumentNullException($"PlayerInningService is null");
            _statistics = statistics ?? throw new ArgumentNullException($"StatisticsService is null");

            Statistics = new List <PlayerStatistics>();
            foreach (var team in _teamService.GetTeams())
            {
                var players = _teamService.GetTeamDetail(team.Id).Players;
                foreach (var player in players)
                {
                    Statistics.Add(_statistics.GetPlayerStatistics(
                                       _playerInningService.GetPlayerInnings(player.Id)));
                }
            }
        }
Ejemplo n.º 5
0
 public BatsmanStatisticsViewModel(ITeamService teamService,
                                   IPlayerInningService playerInningService,
                                   StatisticsService statistics) : base(teamService, playerInningService, statistics)
 {
     BatsmanStatistics = Statistics.OrderByDescending(b => b.Runs).ToList();
 }
Ejemplo n.º 6
0
 public FielderStatisticsViewModel(ITeamService teamService,
                                   IPlayerInningService playerInningService,
                                   StatisticsService statistics) : base(teamService, playerInningService, statistics)
 {
     FielderStatistics = Statistics.OrderByDescending(b => b.Catches).ToList();
 }