public CompetitionSchedule CreateDuringSeasonFriendlyRounds(SeasonCompetition seasonCompetition, List <DateTime> matchDates, int startIndex) { // The during season friendly schedule only consists of rounds. The matches in the rounds are determined during the season. var competitionSchedule = new CompetitionSchedule(); foreach (var matchDate in matchDates) { var friendlyRound = RoundFactory.CreateRound(null, seasonCompetition, matchDate, startIndex, _competition); competitionSchedule.Rounds.Add(friendlyRound); startIndex++; } return(competitionSchedule); }
public CompetitionSchedule CreatePreSeasonSchedule(List <Team> teams, Season season, MatchDateManager matchDateManager) { var competitionSchedule = new CompetitionSchedule(); // Create a friendly season competition for all friendlies in the season. SeasonCompetition friendlySeasonCompetition = new SeasonCompetition { Competition = _competition, Season = season }; competitionSchedule.SeasonCompetitions.Add(friendlySeasonCompetition); var roundsAndMatches = CreatePreSeasonRoundsAndMatches(teams); foreach (var round in roundsAndMatches) { var matchDate = matchDateManager.GetNextMatchDate(CompetitionType.Friendly, round.Key); var friendlyRound = RoundFactory.CreateRound(null, friendlySeasonCompetition, matchDate, round.Key, _competition); competitionSchedule.Rounds.Add(friendlyRound); foreach (var match in round.Value) { match.Season = season; match.Round = friendlyRound; match.Date = matchDate; match.CompetitionId = _competition.Id; competitionSchedule.Matches.Add(match); } } // Add the teams to the pre-season friendly competition of this season. foreach (var team in teams) { var seasonCompetitionTeam = new SeasonCompetitionTeam { SeasonCompetition = friendlySeasonCompetition, Team = team }; competitionSchedule.SeasonCompetitionTeams.Add(seasonCompetitionTeam); } return(competitionSchedule); }