public FilteredDataResponse <ManualByCsQualifiedBonus> Data(PlayerFilteredDataRequest request)
        {
            var qualifiedBonuses = _bonusQueries.GetManualByCsQualifiedBonuses(request.PlayerId).AsQueryable();

            return(new FilteredDataBuilder <ManualByCsQualifiedBonus>(request.DataRequest, qualifiedBonuses)
                   .GetPageData());
        }
Beispiel #2
0
        public void ManualByCs_bonus_is_qualified_during_manual_issuance()
        {
            MakeDeposit(PlayerId);
            CreateFirstDepositBonus(mode: IssuanceMode.ManualByCs);

            BonusQueries.GetManualByCsQualifiedBonuses(PlayerId)
            .ToList()
            .Should()
            .NotBeEmpty();
        }
Beispiel #3
0
        public void Bonus_that_become_active_in_future_is_not_qualified_when_issued_by_Cs()
        {
            MakeDeposit(PlayerId);
            var bonus = CreateFirstDepositBonus(mode: IssuanceMode.AutomaticWithCode);

            bonus.ActiveFrom = bonus.ActiveFrom.AddDays(2);
            bonus.ActiveTo   = bonus.ActiveTo.AddDays(2);

            BonusQueries.GetManualByCsQualifiedBonuses(PlayerId)
            .ToList()
            .Should()
            .BeEmpty();
        }
Beispiel #4
0
        public void Expired_bonus_is_qualifed_when_issued_by_Cs()
        {
            MakeDeposit(PlayerId);
            var bonus = CreateFirstDepositBonus(mode: IssuanceMode.AutomaticWithCode);

            bonus.ActiveFrom = bonus.ActiveFrom.AddDays(-1);
            bonus.ActiveTo   = bonus.ActiveTo.AddDays(-1);

            BonusQueries.GetManualByCsQualifiedBonuses(PlayerId)
            .ToList()
            .Should()
            .NotBeEmpty();
        }
Beispiel #5
0
        public void Bonus_issued_by_Cs_ignores_bonus_application_duration_qualification()
        {
            MakeDeposit(PlayerId);
            var bonus = CreateFirstDepositBonus();

            bonus.DurationType  = DurationType.Custom;
            bonus.DurationStart = SystemTime.Now.AddMinutes(5);
            bonus.DurationEnd   = SystemTime.Now.AddMinutes(10);

            SystemTime.Factory = () => DateTimeOffset.Now.AddMinutes(11);

            BonusQueries.GetManualByCsQualifiedBonuses(PlayerId)
            .ToList()
            .Should()
            .NotBeEmpty();

            SystemTime.Factory = () => DateTimeOffset.Now;
        }
Beispiel #6
0
        public IssueByCsValidator(BonusQueries queries, IBonusRepository repository, IBrandOperations brandOperations)
        {
            CascadeMode = CascadeMode.StopOnFirstFailure;
            Func <Guid, Data.Bonus>        bonusGetter       = bonusId => queries.GetCurrentVersionBonuses().SingleOrDefault(b => b.Id == bonusId);
            Func <Guid, Player>            playerGetter      = playerId => repository.Players.SingleOrDefault(b => b.Id == playerId);
            Func <Guid, Guid, Transaction> transactionGetter = (playerId, transactionId) =>
                                                               playerGetter(playerId).Wallets.SelectMany(w => w.Transactions).SingleOrDefault(t => t.Id == transactionId);

            RuleFor(model => model.BonusId)
            .Must(id => bonusGetter(id) != null)
            .WithMessage(ValidatorMessages.BonusDoesNotExist);

            RuleFor(model => model.PlayerId)
            .Must(id => playerGetter(id) != null)
            .WithMessage(ValidatorMessages.PlayerDoesNotExist);

            When(model => playerGetter(model.PlayerId) != null && bonusGetter(model.BonusId) != null, () =>
            {
                RuleFor(model => model.TransactionId)
                .Must((model, transactionId) => transactionGetter(model.PlayerId, transactionId) != null)
                .WithMessage(ValidatorMessages.TransactionDoesNotExist);

                When(model => transactionGetter(model.PlayerId, model.TransactionId) != null, () => RuleFor(model => model.TransactionId)
                     .Must((model, transactionId) =>
                {
                    var transaction = transactionGetter(model.PlayerId, transactionId);
                    var bonus       = bonusGetter(model.BonusId);

                    if (bonus.Template.Info.TemplateType == BonusType.FundIn)
                    {
                        return(transaction.Type == TransactionType.FundIn);
                    }
                    if (bonus.Template.Info.TemplateType == BonusType.FirstDeposit || bonus.Template.Info.TemplateType == BonusType.ReloadDeposit)
                    {
                        return(transaction.Type == TransactionType.Deposit);
                    }

                    return(true);
                })
                     .WithMessage(ValidatorMessages.TransactionTypeDoesNotMatchBonusType)
                     .Must((model, transactionId) =>
                {
                    var qualifiedBonuses = queries.GetManualByCsQualifiedBonuses(model.PlayerId);
                    var theQualifedBonus = qualifiedBonuses.SingleOrDefault(b => b.Id == model.BonusId);
                    if (theQualifedBonus == null)
                    {
                        return(false);
                    }
                    var qualifiedTransactions = queries.GetManualByCsQualifiedTransactions(model.PlayerId, model.BonusId);
                    if (qualifiedTransactions.Select(tr => tr.Id).Contains(model.TransactionId) == false)
                    {
                        return(false);
                    }

                    return(true);
                })
                     .WithMessage(ValidatorMessages.PlayerIsNotQualifiedForBonus)
                     .Must((model, transactionId) =>
                {
                    var bonus = bonusGetter(model.BonusId);
                    if (bonus.Template.Wagering.HasWagering == false)
                    {
                        return(true);
                    }

                    var bonusWallet = playerGetter(model.PlayerId).Wallets.Single(w => w.Transactions.Select(t => t.Id).Contains(transactionId));
                    var transaction = transactionGetter(model.PlayerId, transactionId);

                    return(bonusWallet.Main >= transaction.TotalAmount);
                })
                     .WithMessage(ValidatorMessages.PlayerHasNoFundsToLockLeft)
                     .Must((model, transactionId) =>
                {
                    var bonus = bonusGetter(model.BonusId);
                    if (bonus.Template.Wagering.HasWagering == false)
                    {
                        return(true);
                    }

                    var player  = playerGetter(model.PlayerId);
                    var balance = brandOperations.GetPlayerBalance(model.PlayerId, player.CurrencyCode);
                    return(balance >= bonus.Template.Wagering.Threshold);
                })
                     .WithMessage(ValidatorMessages.PlayerBalanceIsLessThanWageringThreshold));
            });
        }