Example #1
0
        protected virtual TeamMatch CreateMatch(bool entrant1Home)
        {
            if (this._matches.Count == this.Legs)
            {
                throw new InvalidOperationException("Too many Matches added for this fixture.  Fixture already has enough matches for the configured number of legs.");
            }

            var matchFormat = this.CompetitionRound.CompetitionEvent.GetMatchFormat();
            var leg         = (byte)(this._matches.Count + 1);
            var match       = new TeamMatch
            {
                TeamFixture   = this,
                Date          = this.PendingDate.Value,
                Leg           = leg,
                MatchFormat   = matchFormat,
                MatchStatusID = MatchStatuses.Pending
            };

            match.MatchCalculationEngineID = this.CompetitionRound.CompetitionEvent.GetMatchCalculationEngine();
            match.Home        = entrant1Home ? this.Entrant1 : this.Entrant2;
            match.Away        = entrant1Home ? this.Entrant2 : this.Entrant1;
            match.VenueTypeID = this.PendingVenueTypeID.Value;
            match.Pitch       = this.ResolvePitch(entrant1Home);

            if (leg == 1 && match.Pitch != null)
            {
                match.SetIncomplete();
            }
            else
            {
                match.SetAuditFields();
            }

            this._matches.Add(match);
            return(match);
        }