public async Task <bool> IsSatisfiedBy(ITeamResultEngineContext context, IRevertResultRequest request, ResultsEngineResponse response)
        {
            if (request.UpdatePlayerCompetitionStatistics)
            {
                var match = await context.Fixture.GetMatch(request.MatchID);

                return(context.Competition.PlayerMeritTableCalculationEngineID.HasValue && match.IsMatchProcessedWithResult());
            }

            return(false);
        }
Exemple #2
0
        public ResultsEngineResponse Execute(ITeamResultEngineContext context, IRevertResultRequest request)
        {
            this._unitOfWork.GuardCheckInTransaction();

            var response   = new ResultsEngineResponse();
            var processors = this._processorFactory.Create(context, request);
            var status     = this._processorExecutor.Execute(context, request, response, processors);

            response.Status = status;

            return(response);
        }
        public async Task <bool> IsSatisfiedBy(ITeamResultEngineContext context, IRevertResultRequest request, ResultsEngineResponse response)
        {
            if (request.UpdatePlayerCompetitionStatistics)
            {
                var leagueEvent = context.CompetitionEvent as League;
                if (leagueEvent == null)
                {
                    throw new InvalidResultsEngineOperationException("Invalid type specified for loaded competition event");
                }

                var match = await context.Fixture.GetMatch(request.MatchID);

                return(leagueEvent.MeritCalculationEngineID.HasValue && match.IsMatchProcessedWithResult());
            }

            return(false);
        }
        public async Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IRevertResultRequest request, ResultsEngineResponse response)
        {
            var match = await context.Fixture.GetMatch(request.MatchID);

            var meritTable = await context.GetCompetitionPlayerMeritTable();

            var config = await this._meritCalculationEngineRepository.Get((byte)meritTable.MeritCalculationEngineID);

            foreach (var teamMatchXGame in match.Data.Games)
            {
                foreach (var playerGame in teamMatchXGame.Game.Players.Where(x => x.Player.IsRealPlayer()))
                {
                    var team = match.Data.GetTeamBySide(playerGame.SideID);

                    await this._playerMeritTableCalculationEngine.Remove(meritTable, playerGame, team, context.CompetitionEvent, config);
                }
            }

            //meritTable.MatchAdded(match.Data);

            return(ResultsEngineStatuses.Success);
        }
 public Task <bool> IsSatisfiedBy(ITeamResultEngineContext context, IRevertResultRequest request, ResultsEngineResponse response)
 {
     return(Task.FromResult(context.Fixture.IsMatchProcessedWithResult(request.MatchID)));
 }
        public async Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IRevertResultRequest request, ResultsEngineResponse response)
        {
            var matchModel = await context.Fixture.GetMatch(request.MatchID);

            await this._careerTeamGameStatisticService.Remove(matchModel.Data);

            return(ResultsEngineStatuses.Success);
        }
        public async Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IRevertResultRequest request, ResultsEngineResponse response)
        {
            var matchModel = await context.Fixture.GetMatch(request.MatchID);

            foreach (var teamMatchXGame in matchModel.Data.Games)
            {
                foreach (var gameXPlayer in teamMatchXGame.Game.Players)
                {
                    var dto = new CompetitionPlayerStatisticData();
                    dto.CompetitionHeaderID = context.Competition.CompetitionHeaderID.Value;
                    dto.CompetitionID       = context.Competition.ID;
                    dto.CompetitionStageID  = matchModel.Data.TeamFixture.CompetitionRound.CompetitionEvent.CompetitionStage.ID;
                    dto.CompetitionEventID  = matchModel.Data.TeamFixture.CompetitionRound.CompetitionEvent.ID;
                    dto.TeamMatchXGame      = teamMatchXGame;
                    dto.Game      = gameXPlayer;
                    dto.TeamMatch = matchModel.Data;
                    this._competitionPlayerStatisticService.Remove(dto);
                }
            }

            return(ResultsEngineStatuses.Success);
        }
        public async Task <bool> IsSatisfiedBy(ITeamResultEngineContext context, IRevertResultRequest request, ResultsEngineResponse response)
        {
            var match = await context.Fixture.GetMatch(request.MatchID);

            return(match.IsMatchProcessedWithResult() && request.UpdateCareerStatistics);
        }
Exemple #9
0
        public async Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IRevertResultRequest request, ResultsEngineResponse response)
        {
            var leagueEvent = context.CompetitionEvent.CastEntity <League>();
            var leagueTable = await context.GetLeagueTable();

            var engine = this._leagueTableCalculationEngineFactory.Create(context.Fixture.Data);

            await engine.Remove(leagueEvent, leagueTable, context.Fixture.Data);

            return(ResultsEngineStatuses.Success);
        }
Exemple #10
0
 public Task <bool> IsSatisfiedBy(ITeamResultEngineContext context, IRevertResultRequest request, ResultsEngineResponse response)
 {
     return(context.Fixture.AllMatchesProcessedWithResult());
 }
Exemple #11
0
        public IList <IProcessor <ITeamResultEngineContext, IRevertResultRequest, ResultsEngineResponse> > Create(ITeamResultEngineContext context, IRevertResultRequest request)
        {
            var list = new List <IProcessor <ITeamResultEngineContext, IRevertResultRequest, ResultsEngineResponse> >();

            switch (context.CompetitionStage.CompetitionStageFormatID)
            {
            case CompetitionStageFormats.SingleLeague:
            case CompetitionStageFormats.Groups:
            {
                list.Add(this._validateMatchProcessedProcessor);
                list.Add(this._revertCareerTeamStatisticsProcessor);
                list.Add(this._revertCareerPlayerStatisticsProcessor);
                list.Add(this._revertCompetitionPlayerStatisticsProcessor);
                list.Add(this._revertUpdateCompetitionPlayerMeritTableProcessor);
                list.Add(this._revertUpdateLeaguePlayerMeritTableProcessor);
                list.Add(this._revertUpdateLeagueTableProcessor);
                list.Add(this._clearMatchProcessor);
            }
            break;

            case CompetitionStageFormats.SingleKnockout:
            {
                list.Add(this._validateMatchProcessedProcessor);
                list.Add(this._revertCareerTeamStatisticsProcessor);
                list.Add(this._revertCareerPlayerStatisticsProcessor);
                list.Add(this._revertCompetitionPlayerStatisticsProcessor);
                list.Add(this._revertUpdateCompetitionPlayerMeritTableProcessor);
                list.Add(this._clearMatchProcessor);
            }
            break;

            default:
            {
                throw new ArgumentOutOfRangeException();
            }
            }

            return(list);
        }