public RiskProfileConfiguration Create(RiskProfileCheckDTO data)
        {
            var entity = new RiskProfileConfiguration();

            using (var scope = CustomTransactionScope.GetTransactionScope())
            {
                ValidateData(data, RiskAction.Create);

                entity.Id = Guid.NewGuid();
                CopyFromModel(data, entity);

                entity.CreatedBy = _actorInfoProvider.Actor.Id;

                if (data.HasFraudRiskLevel)
                {
                    foreach (var riskLevelId in data.RiskLevels)
                    {
                        var riskLevel = _fraudRepository.RiskLevels
                                        .Single(x => x.Id == riskLevelId);

                        entity.AllowedRiskLevels.Add(riskLevel);
                    }
                }

                if (data.HasPaymentMethodCheck)
                {
                    foreach (var paymentMethodId in data.PaymentMethods)
                    {
                        var method = _fraudRepository.PaymentMethods
                                     .Single(o => o.Id == paymentMethodId);

                        entity.AllowedPaymentMethods.Add(method);
                    }
                }

                if (data.HasBonusCheck)
                {
                    foreach (var bonusId in data.Bonuses)
                    {
                        var bonus = _fraudRepository.Bonuses
                                    .Single(o => o.Id == bonusId);

                        entity.AllowedBonuses.Add(bonus);
                    }
                }

                _fraudRepository.RiskProfileConfigurations.Add(entity);
                _fraudRepository.SaveChanges();
                scope.Complete();
            }

            _eventBus.Publish(new RiskProfileCheckConfigCreated
            {
                Id          = entity.Id,
                CreatedBy   = _actorInfoProvider.Actor.UserName,
                DateCreated = entity.DateCreated
            });

            return(entity);
        }
Ejemplo n.º 2
0
 public RiskProfileCheckConfigurationBuilder(Guid brandId,
                                             Guid licenseeId,
                                             string currency,
                                             IEnumerable <Guid> vipLevelIds)
 {
     Configuration = new RiskProfileCheckDTO
     {
         Id        = Guid.NewGuid(),
         Brand     = brandId,
         Licensee  = licenseeId,
         Currency  = currency,
         VipLevels = vipLevelIds
     };
 }
Ejemplo n.º 3
0
        public override void BeforeAll()
        {
            base.BeforeAll();

            _paymentTestHelper = _container.Resolve <PaymentTestHelper>();
            _playerCommands    = _container.Resolve <PlayerCommands>();
            _brandTestHelper   = _container.Resolve <BrandTestHelper>();
            _playerTestHelper  = _container.Resolve <PlayerTestHelper>();
            _autoVerificationConfigurationTestHelper = _container.Resolve <AutoVerificationConfigurationTestHelper>();
            _riskProfileCheckTestHelper = _container.Resolve <RiskProfileCheckTestHelper>();

            //create a not default VIP Level for Brand
            _vipLevel = _brandTestHelper.CreateNotDefaultVipLevel(DefaultBrandId);

            //create a player for the DefaultBrandId
            var player   = _playerTestHelper.CreatePlayer(isActive: true, brandId: DefaultBrandId);
            var playerId = player.Id;

            _player         = _container.Resolve <PlayerQueries>().GetPlayer(playerId);
            _playerUsername = _player.Username;

            _paymentTestHelper.CreatePlayerBankAccount(playerId, DefaultBrandId, true);

            //change the VIP Level for Player
            _playerCommands.ChangeVipLevel(playerId, _vipLevel.Id, "changed vip level");

            //deposit
            _paymentTestHelper.MakeDeposit(_playerUsername, 100);
            _paymentTestHelper.MakeDeposit(_playerUsername, 200);
            _paymentTestHelper.MakeDeposit(_playerUsername, 300);

            //create Auto Verification configuration which expected to be failed
            _avcConfigurationBuilder = new AvcConfigurationBuilder(DefaultBrandId, new [] { _vipLevel.Id }, "CAD");
            _avcConfigurationBuilder.SetupTotalDepositAmount(1500, ComparisonEnum.GreaterOrEqual);
            _avcDTO = _avcConfigurationBuilder.Configuration;

            _avc = _autoVerificationConfigurationTestHelper.CreateConfiguration(_avcDTO);
            _autoVerificationConfigurationTestHelper.Activate(_avc.Id);

            //create Risk Profile Check configuration
            _riskProfileCheckConfigurationBuilder = new RiskProfileCheckConfigurationBuilder(DefaultBrandId, _avcDTO.Licensee, "CAD", new List <Guid> {
                _vipLevel.Id
            });
            _rpcDTO = _riskProfileCheckConfigurationBuilder.Configuration;
            var createdConfigurationEntity = _riskProfileCheckTestHelper.CreateConfiguration(_rpcDTO);

            _rpcDTO.Id = createdConfigurationEntity.Id;
        }
        private void CopyFromModel(RiskProfileCheckDTO data, RiskProfileConfiguration entity)
        {
            entity.BrandId  = data.Brand;
            entity.Brand    = _fraudRepository.Brands.First(x => x.Id == data.Brand);
            entity.Currency = data.Currency;

            entity.VipLevels.Clear();
            data.VipLevels
            .ForEach(id =>
            {
                var vipLevel = _fraudRepository.VipLevels
                               .Single(x => x.Id == id);

                entity.VipLevels.Add(vipLevel);
            });

            entity.DateCreated = DateTimeOffset.UtcNow;

            entity.HasWinLoss      = data.HasWinLoss;
            entity.WinLossAmount   = data.WinLossAmount;
            entity.WinLossOperator = data.WinLossOperator;

            entity.HasDepositCount           = data.HasDepositCount;
            entity.TotalDepositCountAmount   = data.TotalDepositCountAmount;
            entity.TotalDepositCountOperator = data.TotalDepositCountOperator;

            entity.HasAccountAge      = data.HasAccountAge;
            entity.AccountAge         = data.AccountAge;
            entity.AccountAgeOperator = data.AccountAgeOperator;

            entity.HasWithdrawalCount           = data.HasWithdrawalCount;
            entity.TotalWithdrawalCountAmount   = data.TotalWithdrawalCountAmount;
            entity.TotalWithdrawalCountOperator = data.TotalWithdrawalCountOperator;

            entity.HasWithdrawalAveragePercentageCheck = data.HasWithdrawalAverageChange;
            entity.WithdrawalAveragePercentageOperator = data.WithdrawalAverageChangeOperator;
            entity.WithdrawalAveragePercentage         = data.WithdrawalAverageChangeAmount;

            entity.HasWinningsToDepositPercentageIncreaseCheck = data.HasWinningsToDepositIncrease;
            entity.WinningsToDepositPercentageIncreaseOperator = data.WinningsToDepositIncreaseOperator;
            entity.WinningsToDepositPercentageIncrease         = data.WinningsToDepositIncreaseAmount;

            entity.HasPaymentMethodCheck = data.HasPaymentMethodCheck;

            entity.HasBonusCheck = data.HasBonusCheck;

            entity.HasFraudRiskLevel = data.HasFraudRiskLevel;
        }
        private void ValidateData(RiskProfileCheckDTO data, RiskAction action)
        {
            var riskProfileConfigurations = _fraudRepository.RiskProfileConfigurations
                                            .Include(o => o.VipLevels)
                                            .AsQueryable();

            if (action == RiskAction.Update)
            {
                riskProfileConfigurations = riskProfileConfigurations
                                            .Where(o => o.Id != data.Id);
            }

            if (riskProfileConfigurations.ToList().Any(
                    record =>
                    record.BrandId == data.Brand &&
                    record.Currency == data.Currency &&
                    record.VipLevels.Select(o => o.Id).Intersect(data.VipLevels).Any()))
            {
                throw new RegoException(
                          "You have already set up Risk Profile Check Configuration with the selected Brand, Currency and Vip level. Please, update the existing one or change your form data.");
            }
        }
 public ActionResult AddOrUpdate(RiskProfileCheckDTO data)
 {
     try
     {
         if (data.Id == Guid.Empty)
         {
             _riskProfileCheckCommands.Create(data);
         }
         else
         {
             _riskProfileCheckCommands.Update(data);
         }
     }
     catch (Exception e)
     {
         return(this.Failed(e));
     }
     return(this.Success(new
     {
         Code = data.Id == Guid.Empty
             ? "successfullyCreated"
             : "successfullyUpdated"
     }));
 }
 public void UpdateConfiguration(RiskProfileCheckDTO configuration)
 {
     _riskProfileCheckCommands.Update(configuration);
 }
 public RiskProfileConfiguration CreateConfiguration(RiskProfileCheckDTO configuration)
 {
     return(_riskProfileCheckCommands.Create(configuration));
 }
        public void Update(RiskProfileCheckDTO data)
        {
            var entity = _fraudRepository.RiskProfileConfigurations
                         .Include(o => o.AllowedPaymentMethods)
                         .Include(o => o.AllowedBonuses)
                         .Include(o => o.AllowedRiskLevels)
                         .Include(o => o.VipLevels)
                         .Single(o => o.Id == data.Id);

            ValidateData(data, RiskAction.Update);

            using (var scope = CustomTransactionScope.GetTransactionScope())
            {
                CopyFromModel(data, entity);

                entity.AllowedRiskLevels.Clear();
                if (data.HasFraudRiskLevel)
                {
                    foreach (var riskLevelId in data.RiskLevels)
                    {
                        var riskLevel = _fraudRepository.RiskLevels
                                        .Single(x => x.Id == riskLevelId);

                        entity.AllowedRiskLevels.Add(riskLevel);
                    }
                }

                entity.AllowedPaymentMethods.Clear();
                if (data.HasPaymentMethodCheck)
                {
                    foreach (var paymentMethodId in data.PaymentMethods)
                    {
                        var method = _fraudRepository.PaymentMethods
                                     .Single(o => o.Id == paymentMethodId);

                        entity.AllowedPaymentMethods.Add(method);
                    }
                }

                entity.AllowedBonuses.Clear();
                if (data.HasBonusCheck)
                {
                    foreach (var bonusId in data.Bonuses)
                    {
                        var bonus = _fraudRepository.Bonuses
                                    .Single(o => o.Id == bonusId);

                        entity.AllowedBonuses.Add(bonus);
                    }
                }

                _fraudRepository.SaveChanges();
                scope.Complete();
            }

            _eventBus.Publish(new RiskProfileCheckConfigUpdated
            {
                Id          = entity.Id,
                UpdatedBy   = _actorInfoProvider.Actor.UserName,
                DateUpdated = DateTimeOffset.Now
            });
        }