Exemple #1
0
        public IHttpActionResult ProductSettings(BrandProductSettingsData data)
        {
            VerifyPermission(Permissions.Create, Modules.SupportedProducts);
            VerifyPermission(Permissions.Create, Modules.BetLevels);
            VerifyPermission(Permissions.Update, Modules.BetLevels);

            _gameCommands.UpdateProductSettings(data);

            return(Ok(true));
        }
Exemple #2
0
        public void UpdateProductSettings(BrandProductSettingsData viewModel)
        {
            var limitsForBrandProduct =
                _repository
                .BetLimits
                .Where(x => x.BrandId == viewModel.BrandId && x.GameProviderId == viewModel.ProductId);

            if (viewModel.BetLevels != null)
            {
                var existingBetLimits = _repository.BetLimits.ToList().Where(x => viewModel.BetLevels.Any(y => y.Id == x.Id));
                var newBetLimits      = viewModel.BetLevels.Where(x => x.Id == Guid.Empty);

                var limitsToDelete =
                    limitsForBrandProduct.ToList().Where(x => !viewModel.BetLevels.Any(y => y.Id == x.Id && x.Id != Guid.Empty));
                limitsToDelete.ToList().ForEach(x =>
                {
                    _eventBus.Publish(new BetLimitDeleted(x));
                    _repository.BetLimits.Remove(x);
                });
                newBetLimits.ToList().ForEach(x =>
                {
                    var limit = new GameProviderBetLimit
                    {
                        Id             = Guid.NewGuid(),
                        BrandId        = viewModel.BrandId,
                        GameProviderId = viewModel.ProductId,
                        Code           = x.Code,
                        Name           = x.Name,
                        Description    = x.Description,
                        DateCreated    = DateTimeOffset.UtcNow,
                        CreatedBy      = _actorInfoProvider.Actor.UserName
                    };
                    _repository.BetLimits.Add(limit);
                    _eventBus.Publish(new BetLimitCreated(limit));
                });

                existingBetLimits.ToList().ForEach(x =>
                {
                    var newLimit  = viewModel.BetLevels.Single(y => y.Id == x.Id);
                    x.Name        = newLimit.Name;
                    x.Description = newLimit.Description;
                    x.Code        = newLimit.Code;
                    x.DateUpdated = DateTimeOffset.UtcNow;
                    x.UpdatedBy   = _actorInfoProvider.Actor.UserName;

                    _eventBus.Publish(new BetLimitUpdated(x));
                });
            }
            else
            {
                limitsForBrandProduct.ToList().ForEach(x => _repository.BetLimits.Remove(x));
            }

            _repository.SaveChanges();
        }
Exemple #3
0
        public IHttpActionResult BetLevels(Guid brandId, Guid productId)
        {
            var data = new BrandProductSettingsData
            {
                BetLevels = _gameQueries
                            .GetBetLimits(productId, brandId)
                            .Select(x => new BetLevelData
                {
                    Id          = x.Id,
                    Code        = x.LimitId,
                    Name        = x.Name,
                    Description = x.Description
                }).ToArray()
            };

            return(Ok(new
            {
                Setting = data,
                Currencies = _brandQueries.GetCurrenciesByBrand(brandId).Select(x => x.Code)
            }));
        }