Exemplo n.º 1
0
 private void GoToNext()
 {
     using (var transactionManager = RepositoryFactory.CreateTransactionManager())
     {
         var mutationManager = new GameDateTimeMutationManager(transactionManager, RepositoryFactory);
         mutationManager.GoToNext();
         transactionManager.Save();
     }
 }
Exemplo n.º 2
0
        private void InsertGameDateTimes(TransactionManager transactionManager, SeasonAndCompetitionSchedules schedules)
        {
            // Determine the match dates the manager's team plays.
            var managersMatchDates = schedules.AllMatches.Where(m => m.TeamPlaysMatch(_managersTeam)).Select(m => m.Date);

            // Determine when the manager's team does not play: all dates in the season except the ones that were just determined.
            var otherTeamsMatchDates = schedules.AllMatchDates.Except(managersMatchDates);

            var gameDateTimeNanager = new GameDateTimeMutationManager(transactionManager, _repositoryFactory);

            gameDateTimeNanager.CreateNewForSeason(managersMatchDates, otherTeamsMatchDates, schedules.Season.EndDateTime);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 public GameDateTimeHandler(ITransactionManager transactionManager, IRepositoryFactory repositoryFactory)
 {
     _gameDateTimeMutationManager = new GameDateTimeMutationManager(transactionManager, repositoryFactory);
 }