public async Task Calculate(TeamMatch match, MatchCalculationEngine engineConfiguration)
        {
            if (match.Games.Count > 0 && match.Games.All(x => x.Game.Completed))
            {
                this.CalculateChalksFromGames(match);
                this.CalculateGamesScoreFromGames(match);

                if (engineConfiguration.BonusPointTypeID != BonusPointTypes.None)
                {
                    this.CalculateBonusPoints(match, engineConfiguration);
                }

                var resultEngine = await this._matchResultCalculationEngineFactory.Create(engineConfiguration.MatchResultCalculationEngineID);

                await resultEngine.Calculate(match);

                match.SetComplete();
            }
            else
            {
                match.SetIncomplete();
            }
        }
Exemplo n.º 2
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);
        }