Example #1
0
        //[Route("available-risk-level")]
        public ActionResult AvailableRiskLevels(Guid brandId)
        {
            var risks = _queries.GetByBrand(brandId).ToList();

            if (risks != null && risks.Count > 0)
            {
                var q = from r in risks
                        select new
                {
                    id   = r.Id,
                    name = string.Format("{0} - {1}", r.Level.ToString(), r.Name)
                };

                var brand = risks.First().Brand;

                return(this.Success(new
                {
                    Licensee = brand.LicenseeName,
                    Brand = brand.Name,
                    RiskLevels = q.ToArray()
                }));
            }

            return(this.Failed("app:fraud.evaluation.message.notAvailableRiskLevel"));
        }
        public string GetFraudRiskLevels(Guid brandId)
        {
            var riskLevels = _riskLevelQueries.GetByBrand(brandId).ToList();

            return(SerializeJson(new
            {
                RiskLevels = riskLevels.Select(x => new { id = x.Id, name = x.Name })
            }));
        }
        public override void BeforeEach()
        {
            base.BeforeEach();

            Balance = new BonusBalance();
            var bonusApiMock = new Mock <IBonusApiProxy>();

            bonusApiMock.Setup(proxy => proxy.GetPlayerBalanceAsync(It.IsAny <Guid>(), It.IsAny <Guid?>())).ReturnsAsync(Balance);
            Container.RegisterInstance(bonusApiMock.Object);

            Container.Resolve <PaymentWorker>().Start();

            _withdrawalService = Container.Resolve <IWithdrawalService>();
            _playerQueries     = Container.Resolve <PlayerQueries>();
            _paymentRepository = Container.Resolve <FakePaymentRepository>();
            _paymentTestHelper = Container.Resolve <PaymentTestHelper>();
            _withdrawalVerificationLogsQueues = Container.Resolve <IWithdrawalVerificationLogsQueues>();
            _riskLevelQueries = Container.Resolve <IRiskLevelQueries>();

            var securityTestHelper = Container.Resolve <SecurityTestHelper>();

            securityTestHelper.PopulatePermissions();
            securityTestHelper.CreateAndSignInSuperAdmin();
            _gamesTestHelper = Container.Resolve <GamesTestHelper>();

            var brandHelper = Container.Resolve <BrandTestHelper>();
            var brand       = brandHelper.CreateActiveBrandWithProducts();

            _brandQueries = Container.Resolve <BrandQueries>();

            _actorInfoProvider = Container.Resolve <IActorInfoProvider>();

            _avcConfigurationCommands = Container.Resolve <IAVCConfigurationCommands>();
            _riskProfileCheckCommands = Container.Resolve <IRiskProfileCheckCommands>();

            var player = Container.Resolve <PlayerTestHelper>().CreatePlayer();

            _paymentTestHelper.CreatePlayerBankAccount(player.Id, brand.Id, true);
            _observedBrand = _brandQueries.GetBrands().First();

            brandHelper.CreateRiskLevel(_observedBrand.Id);

            //Replace with risk levels from fraud repository
            var availableRiskLevels = _riskLevelQueries.GetByBrand(_observedBrand.Id);

            _observedRiskLevel = availableRiskLevels.FirstOrDefault().Id;

            _riskLevelDifferentThanObserved = availableRiskLevels.First(rl => rl.Id != _observedRiskLevel).Id;
        }
        public async Task <TemplateDataResponse> GetRelatedData(Guid?id = null)
        {
            VerifyPermission(Permissions.View, Modules.BonusTemplateManager);
            VerifyPermission(Permissions.View, Modules.BonusManager);

            Template template = null;

            if (id.HasValue)
            {
                var templateData = await _bonusApiProxy.GetTemplateOrNull(id.Value);

                template = Mapper.Map <Template>(templateData);
                CheckBrand(template.Info.BrandId.Value);
            }

            var getBonusesTask = _bonusApiProxy.GetBonusesAsync();

            var notificationTriggers = _messageTemplateQueries.GetBonusNotificationTriggerMessageTypes()
                                       .Select(x => Enum.GetName(typeof(MessageType), x));

            var licenseeFilterSelections = _adminQueries.GetLicenseeFilterSelections();
            var brandFilterSelections    = _adminQueries.GetBrandFilterSelections();

            var licensees = _brandQueries.GetFilteredLicensees()
                            .Include(l => l.Brands.Select(b => b.VipLevels))
                            .Include(l => l.Brands.Select(b => b.BrandCurrencies.Select(bc => bc.Currency)))
                            .Include(l => l.Brands.Select(b => b.WalletTemplates))
                            .Include(l => l.Brands.Select(b => b.Products))
                            .Where(l => licenseeFilterSelections.Contains(l.Id))
                            .OrderBy(l => l.Name)
                            .ToList()
                            .Select(l => new Licensee
            {
                Id     = l.Id,
                Name   = l.Name,
                Brands = _brandQueries.GetFilteredBrands(l.Brands, UserId)
                         .Where(b =>
                                b.Status == BrandStatus.Active &&
                                brandFilterSelections.Contains(b.Id))
                         .OrderBy(b => b.Name)
                         .Select(b => new TemplateBrand
                {
                    Id        = b.Id,
                    Name      = b.Name,
                    VipLevels = b.VipLevels.Select(v => new TemplateVipLevel {
                        Code = v.Code, Name = v.Name
                    }),
                    Currencies = b.BrandCurrencies.Select(v => new TemplateCurrency {
                        Code = v.Currency.Code, Name = v.Currency.Name
                    }),
                    WalletTemplates = b.WalletTemplates.OrderBy(wt => wt.Name).Select(wt => new TemplateWalletTemplate {
                        Id = wt.Id, Name = wt.Name, IsMain = wt.IsMain
                    }),
                    Products   = b.Products.Select(p => p.ProductId),
                    RiskLevels = _riskLevelQueries.GetByBrand(b.Id)
                                 .Select(riskLevel => new TemplateRiskLevel {
                        Id = riskLevel.Id, Name = riskLevel.Name
                    })
                                 .OrderBy(riskLevel => riskLevel.Name)
                })
            }).ToList();

            var products = _gameQueries.GetGameProviders().ToList();
            var games    =
                _gameQueries.GetGameDtos()
                .Select(g => new Game {
                Id = g.Id.Value, Name = g.Name, ProductId = g.ProductId, ProductName = products.Single(p => p.Id == g.ProductId).Name
            })
                .ToList();

            if (template != null)
            {
                if (template.Info != null)
                {
                    template.Info.LicenseeId   = licensees.Single(l => l.Brands.Select(b => b.Id).Contains(template.Info.BrandId.Value)).Id;
                    template.Info.LicenseeName = licensees.Single(l => l.Brands.Select(b => b.Id).Contains(template.Info.BrandId.Value)).Name;
                    template.Info.BrandName    = licensees.SelectMany(l => l.Brands).Single(b => b.Id == template.Info.BrandId).Name;
                }

                if (template.Wagering != null)
                {
                    foreach (var gc in template.Wagering.GameContributions)
                    {
                        var game = games.Single(g => g.Id == gc.GameId);
                        gc.Name        = game.Name;
                        gc.ProductId   = game.ProductId;
                        gc.ProductName = game.ProductName;
                    }
                }
            }

            var bonuses = await getBonusesTask;

            bonuses = bonuses.Where(b => brandFilterSelections.Contains(b.BrandId)).OrderBy(bonus => bonus.Name).ToList();

            return(new TemplateDataResponse
            {
                Template = template,
                NotificationTriggers = notificationTriggers,
                Bonuses = bonuses,
                Licensees = licensees,
                Games = games
            });
        }