Esempio n. 1
0
        public void Handle(PostMatchData postMatchData)
        {
            var teamStatisticsManager = new TeamStatisticsManager(postMatchData.TeamStatistics);

            // Update the season team statistics for this season.
            teamStatisticsManager.Update(postMatchData.LeagueTables.Values, postMatchData.Leagues);
        }
Esempio n. 2
0
        public void EndSeason(Season season, TransactionManager transactionManager)
        {
            // Get all league tables and update the team statistics.
            using (var leagueTableRepository = _repositoryFactory.CreateLeagueTableRepository())
                using (var competitionRepository = _repositoryFactory.CreateCompetitionRepository())
                    using (var teamStatisticsRepository = _repositoryFactory.CreateTeamStatisticsRepository())
                    {
                        var teamStatistics        = teamStatisticsRepository.GetAll().ToDictionary(k => k.TeamId, v => v);
                        var teamStatisticsManager = new TeamStatisticsManager(teamStatistics);

                        var leagueTables = leagueTableRepository.GetBySeason(season.Id);
                        var leagues      = competitionRepository.GetLeagues().ToDictionary(k => k.Id, v => v);
                        teamStatisticsManager.Update(leagueTables, leagues);
                    }

            // End the season by updating the status.
            season.SeasonStatus = SeasonStatus.Ended;
            transactionManager.RegisterUpdate(season);

            // Mark the end of season date as completed.
            var gameDateTimeManager = new GameDateTimeMutationManager(transactionManager, _repositoryFactory);

            gameDateTimeManager.UpdateEndOfSeasonStatus(season.EndDateTime);
        }