public NationalLeagueSeason CreateEuroLeague(IEnumerable<Team> championsLeagueClubs, IEnumerable<Team> europaLeagueClubs) { var league = new NationalLeague(world, "European Cups"); var championsLeague = new League(league, "Champions League", 1, DayOfWeek.Wednesday, 2, hasReturnRound: false); championsLeague.AutomaticRelegationCount = 2; championsLeague.ConditionalRelegationCount = 2; league.AddDivision(championsLeague); var europaCup = new Cup(league, "Europa League", 2, DayOfWeek.Thursday, 2, new List<CupStage> { new GroupStage(groupCount: 4, groupTeamCount: 4, groupPromotedCount: 2, isNeutralGround: false, hasReturnRound: true), new TieKnockoutStage(4), new TieKnockoutStage(2) }); league.AddDivision(europaCup); league.PlayOffs = new LeaguePlayOffs(league, "European Play-Offs", DayOfWeek.Wednesday); DateTime startDate = new DateTime(world.StartYear, 08, 21); DateTime endDate = new DateTime(world.StartYear + 1, 05, 16); var leagueSeason = new NationalLeagueSeason(league, startDate, endDate); leagueSeason.AddDivisionSeason(new LeagueSeason((League)league.Divisions[0], startDate, endDate, championsLeagueClubs)); leagueSeason.AddDivisionSeason(new CupSeason((Cup)league.Divisions[1], startDate, endDate, europaLeagueClubs)); return leagueSeason; }
public int CreateLeague(int worldId, string name, DateTime startDate, DateTime endDate) { var world = Context.Worlds.Find(worldId); var league = new NationalLeague(world, name); var leagueSeason = new NationalLeagueSeason(league, startDate, endDate); league.PlayOffs = new LeaguePlayOffs(league, name + " Play-offs", DayOfWeek.Wednesday); Context.NationalLeagues.Add(league); Context.NationalLeagueSeasons.Add(leagueSeason); Context.SaveChanges(); return league.Id; }
public override CompetitionSeason AdvanceSeason() { var newDivisionSeasons = new List<TournamentSeason>(); var divisions = Divisions.OrderBy(d => d.Level).ToArray(); for (int level = 1; level <= divisions.Length; level++) { var relegatedFromHigher = level > 1 ? divisions[level - 2].RelegatedTeams : Enumerable.Empty<Team>(); var promotedFromLower = level < divisions.Length ? divisions[level].PromotedTeams : Enumerable.Empty<Team>(); var newDivisionSeason = divisions[level - 1].AdvanceSeason(relegatedFromHigher, promotedFromLower); newDivisionSeasons.Add(newDivisionSeason); } PlayOffs.AdvanceSeason(Enumerable.Empty<Team>(), Enumerable.Empty<Team>()); IsActive = false; var newSeason = new NationalLeagueSeason(League, StartDate.AddYears(1), EndDate.AddYears(1)); newSeason.Divisions = newDivisionSeasons; return newSeason; }