Пример #1
0
        public Guid AddBrand(AddBrandRequest addBrandRequest)
        {
            var validationResult = ValidateThatBrandCanBeAdded(addBrandRequest);

            if (!validationResult.IsValid)
            {
                throw new RegoValidationException(validationResult);
            }

            var brand = new Interface.Data.Brand
            {
                Id                     = addBrandRequest.Id ?? Guid.NewGuid(),
                LicenseeId             = addBrandRequest.Licensee,
                Licensee               = _repository.Licensees.Single(x => x.Id == addBrandRequest.Licensee),
                Code                   = addBrandRequest.Code,
                Name                   = addBrandRequest.Name,
                Email                  = addBrandRequest.Email,
                SmsNumber              = addBrandRequest.SmsNumber,
                WebsiteUrl             = Uri.EscapeUriString(addBrandRequest.WebsiteUrl),
                Type                   = addBrandRequest.Type,
                TimezoneId             = addBrandRequest.TimeZoneId,
                EnablePlayerPrefix     = addBrandRequest.EnablePlayerPrefix,
                PlayerPrefix           = addBrandRequest.PlayerPrefix,
                PlayerActivationMethod = addBrandRequest.PlayerActivationMethod,
                Status                 = BrandStatus.Inactive,
                CreatedBy              = _actorInfoProvider.Actor.UserName,
                DateCreated            = DateTimeOffset.Now.ToBrandOffset(addBrandRequest.TimeZoneId)
            };

            using (var scope = CustomTransactionScope.GetTransactionScope())
            {
                _repository.Brands.Add(brand);
                _repository.SaveChanges();

                _adminCommands.AddBrandToAdmin(_actorInfoProvider.Actor.Id, brand.Id);
                _eventBus.Publish(new BrandRegistered
                {
                    Id                     = brand.Id,
                    Code                   = brand.Code,
                    Name                   = brand.Name,
                    Email                  = brand.Email,
                    SmsNumber              = brand.SmsNumber,
                    WebsiteUrl             = brand.WebsiteUrl,
                    LicenseeId             = brand.Licensee.Id,
                    LicenseeName           = brand.Licensee.Name,
                    TimeZoneId             = brand.TimezoneId,
                    BrandType              = brand.Type,
                    Status                 = brand.Status,
                    PlayerPrefix           = brand.PlayerPrefix,
                    InternalAccountsNumber = brand.InternalAccountsNumber,
                    EventCreated           = DateTimeOffset.Now.ToBrandOffset(brand.TimezoneId),
                });
                scope.Complete();
            }

            return(brand.Id);
        }
Пример #2
0
        public AssignBrandCurrencyValidator(IBrandRepository repository)
        {
            CascadeMode = CascadeMode.StopOnFirstFailure;

            Interface.Data.Brand brand = null;

            RuleFor(x => x.Brand)
            .Must(x =>
            {
                brand = repository.Brands
                        .Include(y => y.BrandCurrencies)
                        .SingleOrDefault(y => y.Id == x);

                return(brand != null);
            })
            .WithMessage(AssignBrandCurrencyResponseCodes.InvalidBrand)
            .DependentRules(x =>
            {
                RuleFor(y => y.Currencies)
                .NotNull()
                .Must(y => y.Any())
                .WithMessage(AssignBrandCurrencyResponseCodes.Required)
                .Must(y =>
                {
                    var licensee = repository.Licensees
                                   .Include(z => z.Currencies)
                                   .SingleOrDefault(z => z.Id == brand.LicenseeId);

                    var allowedCurrencies = licensee
                                            .Currencies
                                            .Select(z => z.Code)
                                            .ToArray();

                    var allCurrenciesAllowed = y.All(allowedCurrencies.Contains);

                    return(allCurrenciesAllowed);
                })
                .WithMessage(AssignBrandCurrencyResponseCodes.InvalidCurrency);

                RuleFor(y => y.BaseCurrency)
                .NotEmpty()
                .WithMessage(AssignBrandCurrencyResponseCodes.Required)
                .Must((data, y) => data.Currencies.Contains(y))
                .WithMessage(AssignBrandCurrencyResponseCodes.InvalidBaseCurrency);

                RuleFor(y => y.DefaultCurrency)
                .NotEmpty()
                .WithMessage(AssignBrandCurrencyResponseCodes.Required)
                .Must((data, y) => data.Currencies.Contains(y))
                .WithMessage(AssignBrandCurrencyResponseCodes.InvalidDefaultCurrency);
            });
        }
Пример #3
0
        public void Consume(BrandRegistered @event)
        {
            var brand = new Interface.Data.Brand
            {
                Id         = @event.Id,
                Code       = @event.Code,
                LicenseeId = @event.LicenseeId,
                TimezoneId = @event.TimeZoneId
            };

            _repository.Brands.Add(brand);

            _repository.SaveChanges();
        }
Пример #4
0
        public void SetDefaultVipLevel(Interface.Data.Brand brand, Guid vipLevelId)
        {
            var oldVipLevelId = brand.DefaultVipLevelId;

            brand.DefaultVipLevelId = vipLevelId;

            _eventBus.Publish(new BrandDefaultVipLevelChanged
            {
                BrandId           = brand.Id,
                OldVipLevelId     = oldVipLevelId,
                DefaultVipLevelId = vipLevelId,
                EventCreated      = DateTimeOffset.Now.ToBrandOffset(brand.TimezoneId),
            });
            _repository.SaveChanges();
        }
Пример #5
0
 public Round(string externalBetId, Guid gameId, Guid playerId, Interface.Data.Brand brand) : this()
 {
     Data = new Interface.Data.Round
     {
         Id              = Guid.NewGuid(),
         Status          = RoundStatus.New,
         ExternalRoundId = externalBetId,
         PlayerId        = playerId,
         GameId          = gameId,
         BrandId         = brand.Id,
         Brand           = brand,
         CreatedOn       = DateTimeOffset.UtcNow.ToBrandOffset(brand.TimezoneId),
         GameActions     = new List <GameAction>()
     };
 }
Пример #6
0
        }                                   // default constructor is required for publishing event to MQ

        public BrandCountriesAssigned(Interface.Data.Brand brand)
        {
            BrandId   = brand.Id;
            Countries = brand.BrandCountries.Select(x => x.Country).ToList();
        }
Пример #7
0
 public Wallet()
 {
     Id           = Guid.NewGuid();
     Transactions = new List <Transaction>();
     Brand        = new Interface.Data.Brand();
 }