Пример #1
0
        private Season InsertSeasonAndCompetitionSchedule(IUnitOfWorkRepository repository, SeasonAndCompetitionSchedules seasonAndCompetitionSchedules)
        {
            // Insert the season.
             repository.RegisterInsert(seasonAndCompetitionSchedules.Season);

             // Insert league schedules.
             SaveCompetitionSchedule(seasonAndCompetitionSchedules.LeaguesSchedule, repository);

             // Insert cup schedule.
             SaveCompetitionSchedule(seasonAndCompetitionSchedules.NationalCupSchedule, repository);

             // Insert super cup schedule.
             SaveCompetitionSchedule(seasonAndCompetitionSchedules.NationalSuperCupSchedule, repository);

             // Insert pre-season friendly schedule.
             SaveCompetitionSchedule(seasonAndCompetitionSchedules.PreSeasonFriendliesSchedule, repository);

             // Update the teams.
             repository.RegisterUpdate(seasonAndCompetitionSchedules.Teams);

             return seasonAndCompetitionSchedules.Season;
        }
Пример #2
0
        private SeasonAndCompetitionSchedules CreateSeasonAndCompetitionSchedules(NewSeasonInfo newSeasonInfo)
        {
            var seasonAndCompetitionSchedules = new SeasonAndCompetitionSchedules();

             // Create a new season.
             string seasonName = $"Season {newSeasonInfo.SeasonNumber + 1}";
             var season = new Season
             {
            Name = seasonName,
            GameOrder = newSeasonInfo.SeasonNumber,
            Game = newSeasonInfo.Game,
            SeasonStatus = SeasonStatus.Started
             };

             seasonAndCompetitionSchedules.Season = season;

             var competitionManagerFactory = new CompetitionManagerFactory();
             var matchDateManager = new MatchDateManager(newSeasonInfo.SeasonNumber);
             matchDateManager.Initialize();

             // Create leagues and schedule.
             var leagueManager = competitionManagerFactory.CreateLeagueManager();
             seasonAndCompetitionSchedules.LeaguesSchedule = leagueManager.CreateSchedules(newSeasonInfo.TeamsLeague1, newSeasonInfo.TeamsLeague2, newSeasonInfo.TeamsLeague3, newSeasonInfo.TeamsLeague4, season, matchDateManager);

             // Create a national cup tournament.
             var nationalCupManager = competitionManagerFactory.CreateNationalCupManager();
             seasonAndCompetitionSchedules.NationalCupSchedule = nationalCupManager.CreateSchedule(newSeasonInfo.AllTeams.ToList(), season, matchDateManager);

             // Create friendlies and save it to the database.
             var friendlyManager = competitionManagerFactory.CreateFriendlyManager();
             seasonAndCompetitionSchedules.PreSeasonFriendliesSchedule = friendlyManager.CreatePreSeasonSchedule(
            newSeasonInfo.TeamsLeague1,
            newSeasonInfo.TeamsLeague2,
            newSeasonInfo.TeamsLeague3,
            newSeasonInfo.TeamsLeague4,
            4,
            season,
            matchDateManager);

             // Create Super Cup and save it to the database.
             var nationalSuperCupManager = competitionManagerFactory.CreateNationalSuperCupManager();
             seasonAndCompetitionSchedules.NationalSuperCupSchedule = nationalSuperCupManager.CreateSchedule(newSeasonInfo.NationalChampion, newSeasonInfo.NationalCupWinner, season, matchDateManager);

             // In the mean time data of the teams has changed, so add them to the SeasonAndCompetitionSchedules object so they can be updated in the database.
             seasonAndCompetitionSchedules.Teams = newSeasonInfo.AllTeams;

             return seasonAndCompetitionSchedules;
        }