Example #1
0
 public async void OnCompetitionEventProcessed(CompetitionEvent evt)
 {
     await Clients.All.SendAsync("OnCompetitionEventProcessed",
                                 JsonConvert.SerializeObject(
                                     new
     {
         Date          = evt.Date,
         Country       = evt.Competition.Country.Name,
         CompetitionId = evt.Competition.Id,
         Competition   = evt.Competition.Name,
         Event         = evt.Name
     }
                                     ));
 }
Example #2
0
        public static CompetitionEventDto ToDto(this CompetitionEvent competitionEvent)
        {
            if (competitionEvent is League league)
            {
                return(league.ToDto());
            }

            if (competitionEvent is Knockout knockout)
            {
                return(knockout.ToDto());
            }

            throw new ArgumentOutOfRangeException();
        }
Example #3
0
        private async Task Load(AddPlayerFixtureCommand command)
        {
            await this._competitionRepository.GetForUpdate(command.Competition.CompetitionID);

            this._competition = await this._competitionRepository.GetWithStages(command.Competition.CompetitionID);

            this._competitionStage = this._competition.GetStage(command.Competition.CompetitionStageLookupMode, command.Competition.CompetitionStageValue);
            this._competitionEvent = await this._competitionEventRepository.Get(command.CompetitionEventID);

            var rounds = await this._playerCompetitionRoundRepository.GetAll(this._competitionEvent.ID);

            await this.LoadRound(command, rounds);

            await this.LoadEntrants(command);

            await this.PendingFixtures(command);
        }
Example #4
0
        private async Task <DefaultIdentityCommandResponse> CreateFixture(CompetitionEntrantResult result, Entities.Competition competition, CompetitionEvent compEvent, CompetitionEntrant winnerEntrant, CompetitionEntrant loserEntrant)
        {
            var command = new AddPlayerFixtureCommand
            {
                Competition = new CompetitionLookupModel
                {
                    CompetitionID = result.CompetitionID,
                    CompetitionStageLookupMode = CompetitionLookupModel.CompetitionStageLookupModes.Auto
                },
                CompetitionEventID = compEvent.ID,
                Round = new CompetitionRoundLookupModel
                {
                    RoundType       = CompetitionRoundTypes.Final,
                    GameNumber      = 0,
                    CreateIfMissing = true
                },
                Date      = competition.StartDate,
                TotalLegs = 1,
                VenueType = VenueTypes.Neutral,
                Entrant1  = new PlayerFixtureEntrantConfigurationModel
                {
                    Mode      = PlayerFixtureEntrantConfigurationModel.PendingEntrantModes.Manual,
                    EntrantID = winnerEntrant.ID
                },
                Entrant2 = new PlayerFixtureEntrantConfigurationModel
                {
                    Mode      = PlayerFixtureEntrantConfigurationModel.PendingEntrantModes.Manual,
                    EntrantID = loserEntrant.ID
                },
                Reference = "F"
            };
            var commandHandler = this._serviceProvider.GetService <AddPlayerFixtureCommandHandler>();

            return(await commandHandler.Handle(command));
        }
 public async Task Initialise(Entities.Competition competition, CompetitionStage stage, CompetitionEvent competitionEvent, CompetitionRound round, ITeamFixtureModel teamFixture)
 {
     this.Competition      = competition;
     this.CompetitionStage = stage;
     this.CompetitionEvent = competitionEvent;
     this.CompetitionRound = round;
     this.Fixture          = teamFixture;
 }
        private void CalculateAdditionalData(PlayerMeritTableLine line, GameXPlayer playerGame, CompetitionEvent competitionEvent, MeritCalculationEngine config, IGameCalculationEngine engine, List <int> opponentScoresInWonGames,
                                             List <int> playerScoresInLostGames)
        {
            line.DataDecimal1 = CalculationHelper.CalculateAvLost(line, engine);
            line.DataDecimal2 = CalculationHelper.CalculateAvAll(line);

            if (config.EnableDropWorseResults)
            {
                this.SnapshotTotals(line);
                this.CalculateForDroppedGames(line, opponentScoresInWonGames, playerScoresInLostGames, competitionEvent.DataInt1.Value, competitionEvent.DataInt2.Value, engine);
            }

            line.DataString1 = ListHelper.ListToCsv(opponentScoresInWonGames);
            line.DataString2 = ListHelper.ListToCsv(playerScoresInLostGames);
        }
        public Task Remove(PlayerMeritTable playerMeritTable, GameXPlayer playerGame, Team team, CompetitionEvent competitionEvent, MeritCalculationEngine config)
        {
            var line = playerMeritTable.GetOrCreateLine(team, playerGame.Player);
            var gameCalculationEngine = this._gameCalculationEngineFactory.Create(playerGame.Game.GameCalculationEngineID);

            line.Remove(playerGame);
            var droppedChalks = gameCalculationEngine.CalculateDroppedChalks(playerGame);

            line.RemoveDroppedChalks(playerGame, droppedChalks);

            var opponentScoresInWonGames = ListHelper.ConvertToList(line.DataString1);
            var playerScoresInLostGames  = ListHelper.ConvertToList(line.DataString2);

            ListHelper.RemoveResultFromLists(playerGame, opponentScoresInWonGames, playerScoresInLostGames);

            this.CalculateAdditionalData(line, playerGame, competitionEvent, config, gameCalculationEngine, opponentScoresInWonGames, playerScoresInLostGames);

            return(Task.CompletedTask);
        }
Example #8
0
 public async void OnCompetitionEventProcessing(CompetitionEvent evt)
 {
     //
 }
Example #9
0
 public void Initialise(Entities.Competition competition, CompetitionStage stage, CompetitionEvent competitionEvent, CompetitionRound round,
                        IPlayerFixtureModel playerFixture)
 {
     this.Competition      = competition;
     this.CompetitionStage = stage;
     this.CompetitionEvent = competitionEvent;
     this.CompetitionRound = round;
     this.PlayerFixture    = playerFixture;
 }