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(); }
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(); } }