Ejemplo n.º 1
0
        public async Task <MatchCalculationEngine> GetMatchCalculationEngineConfiguration()
        {
            if (this._matchCalculationEngineConfiguration == null)
            {
                this._matchCalculationEngineConfiguration = await this._matchCalculationEngineRepository.Get((short)this.Data.MatchCalculationEngineID);
            }

            return(this._matchCalculationEngineConfiguration);
        }
        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();
            }
        }
        public async Task OverrideAndCalculate(TeamMatch match, short homeGames, short homeChalks, short awayGames, short awayChalks, MatchCalculationEngine engineConfiguration)
        {
            match.HomeGameScore  = homeGames;
            match.HomeChalkScore = homeChalks;
            match.AwayGameScore  = awayGames;
            match.AwayChalkScore = awayChalks;

            if (match.HomeChalkHandicap.HasValue)
            {
                match.HomeChalkScore += match.HomeChalkHandicap;
            }

            if (match.AwayChalkHandicap.HasValue)
            {
                match.AwayChalkScore += match.AwayChalkHandicap;
            }

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

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

            await resultEngine.Calculate(match);

            match.SetComplete();
        }