public async Task <ITeamResultEngine> GetEngine(IResultsEngineRequest request) { this._unitOfWork.GuardCheckInTransaction(); await this._competitionRepository.GetForUpdate(request.CompetitionID); Entities.Competition competition = await this._competitionRepository.GetWithStages(request.CompetitionID); CompetitionStage stage = this.GetStage(competition, request.CompetitionStageLoadMode, request.CompetitionStageValue); TeamFixture fixture = await this._fixtureRepository.GetTeamFixtureFull(request.FixtureID); if (fixture.CompetitionRound.Competition.ID != competition.ID) { throw new ArgumentException("Incorrect competition/fixture ID combination", nameof(request)); } ITeamFixtureModel teamFixtureModel = this._serviceProvider.GetService <ITeamFixtureModel>(); ITeamResultEngineContext context = this._serviceProvider.GetService <ITeamResultEngineContext>(); await context.Initialise(competition, stage, fixture.CompetitionRound.CompetitionEvent, fixture.CompetitionRound, teamFixtureModel); var engine = this._serviceProvider.GetService <ITeamResultEngine>(); engine.SetContext(context); await teamFixtureModel.Initialise(fixture, context); return(engine); }
public async Task <bool> IsSatisfiedBy(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { var matchModel = await context.Fixture.GetMatch(request.MatchID); var handicapSetting = context.Fixture.GetHandicapSetting(); var result = handicapSetting != null && !matchModel.IsProcessed() && matchModel.HasGamesAndAllGamesProcessed(); return(result); }
public async Task <bool> IsSatisfiedBy(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { if (context.Fixture.Completed) { var pendingFixtures = await context.GetPendingFixtures(); return(pendingFixtures.Count > 0); } return(false); }
public async Task <IPlayerResultEngine> GetEngine(IResultsEngineRequest request) { await this._competitionRepository.GetForUpdate(request.CompetitionID); Entities.Competition competition = await this._competitionRepository.GetWithStages(request.CompetitionID); CompetitionStage stage = this.GetStage(competition, request.CompetitionStageLoadMode, request.CompetitionStageValue); PlayerFixture fixture = await this._playerFixtureRepository.GetFull(request.FixtureID); IPlayerFixtureModel playerFixtureModel = this._serviceProvider.GetService <IPlayerFixtureModel>(); IPlayerResultEngineContext context = this._serviceProvider.GetService <IPlayerResultEngineContext>(); context.Initialise(competition, stage, fixture.CompetitionRound.CompetitionEvent, fixture.CompetitionRound, playerFixtureModel); var engine = this._serviceProvider.GetService <IPlayerResultEngine>(); engine.SetContext(context); await playerFixtureModel.Initialise(fixture, context); return(engine); }
public Task <bool> IsSatisfiedBy(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { return(Task.FromResult(!context.Fixture.IsMatchProcessed(request.MatchID))); }
public Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { response.ValidationResult.Errors.Add(new ValidationFailure("MatchStatus", "Match must have a result to revert.")); return(Task.FromResult(ResultsEngineStatuses.ValidationError)); }
public async Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { await context.Fixture.CalculateFixture(); return(ResultsEngineStatuses.Success); }
public Task <bool> IsSatisfiedBy(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { return(Task.FromResult(true)); }
public async Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { var leagueEvent = context.CompetitionEvent.CastEntity <League>(); var leagueTable = await context.GetLeagueTable(); var engine = this._leagueTableCalculationEngineFactory.Create(context.Fixture.Data); await engine.Add(leagueEvent, leagueTable, context.Fixture.Data); return(ResultsEngineStatuses.Success); }
public Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { if (context.Fixture.IsMatchPending(request.MatchID)) { response.ValidationResult.Errors.Add(new ValidationFailure("MatchStatus", "Match is pending. To make changes you will need to confirm the match details first.")); } if (context.Fixture.IsMatchProcessed(request.MatchID)) { response.ValidationResult.Errors.Add(new ValidationFailure("MatchStatus", "Match has already been processed. To make changes you will need to revert this match first.")); } return(ResultEngineStatusMapper.MapFromValidationResult(response.ValidationResult)); }
public async Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { var match = await context.Fixture.GetMatch(request.MatchID); var engine = this._teamMatchHandicapCalculationEngineFactory.Create(context.Fixture.GetHandicapSetting()); await engine.Calculate(match.Data); return(ResultsEngineStatuses.Success); }
public Task <ResultsEngineStatuses> Process(IPlayerResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { // TODO - use validation result if (context.PlayerFixture.IsMatchPending(request.MatchID)) { throw new InvalidResultsEngineOperationException("Match is pending. To make changes you will need to confirm the match details first."); } if (context.PlayerFixture.IsMatchProcessed(request.MatchID)) { throw new InvalidResultsEngineOperationException("Match has already been processed. To make changes you will need to revert this match first."); } return(Task.FromResult(ResultsEngineStatuses.Success)); }
public async Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { var matchModel = await context.Fixture.GetMatch(request.MatchID); await this._careerTeamGameStatisticService.Add(matchModel.Data); return(ResultsEngineStatuses.Success); }
public async Task <bool> IsSatisfiedBy(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { var match = await context.Fixture.GetMatch(request.MatchID); return(match.IsMatchProcessedWithResult()); }
public async Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { var match = await context.Fixture.GetMatch(request.MatchID); var matchCalculationConfiguration = await match.GetMatchCalculationEngineConfiguration(); if (!matchCalculationConfiguration.AllowDraw) { if (match.Data.IsDraw()) { response.ValidationResult.Errors.Add(new ValidationFailure("MatchResult", "Match has ended in a draw which is not allowed")); } } return(await ResultEngineStatusMapper.MapFromValidationResult(response.ValidationResult)); }
public Task <bool> IsSatisfiedBy(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { return(context.Fixture.AllMatchesProcessedWithResult()); }
public async Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { var status = ResultsEngineStatuses.Success; var pendingFixtures = await context.GetPendingFixtures(); foreach (TeamFixture pendingFixture in pendingFixtures) { var updateRequest = UpdatePendingTeamFixtureRequest.New() .WithCompetitionID(pendingFixture.CompetitionID) .WithFixtureID(pendingFixture.ID) .WithCompetitionStageID(pendingFixture.CompetitionRound.CompetitionEvent.CompetitionStage.ID) .WithCompletedFixture(context.Fixture.Data) .Build(); ITeamResultEngine engine = await this._teamResultEngineManager.GetEngine(updateRequest); var updateResponse = engine.UpdatePendingFixture(updateRequest); status = updateResponse.Status; if (status != ResultsEngineStatuses.Success) { break; } } return(status); }
public async Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { var fixtureModel = context.Fixture; var matchModel = await fixtureModel.GetMatch(request.MatchID); matchModel.Data.ClearScores(); foreach (var teamMatchXGame in matchModel.Data.Games) { await this._sessionProvider.Session.DeleteAsync(teamMatchXGame); foreach (var gameXPlayer in teamMatchXGame.Game.Players) { await this._sessionProvider.Session.DeleteAsync(gameXPlayer); } await this._sessionProvider.Session.DeleteAsync(teamMatchXGame.Game); } matchModel.Data.ClearGames(); await fixtureModel.CalculateFixture(); return(ResultsEngineStatuses.Success); }