public IHttpActionResult SetCurrentBankAccount(SetCurrentPlayerBankAccountData data)
        {
            VerifyPermission(Permissions.Update, Modules.PlayerBankAccount);

            var validationResult = _playerBankAccountCommands.ValidateThatPlayerBankAccountCanBeSet(data);

            if (!validationResult.IsValid)
            {
                return(Ok(ValidationExceptionResponse(validationResult.Errors)));
            }

            _playerBankAccountCommands.SetCurrent(data.PlayerBankAccountId);
            return(Ok(new { Result = "success" }));
        }
Пример #2
0
        public void ThenCurrentBankAccountIsSuccessfullySet()
        {
            ScenarioContext.Current.Should().ContainKey("bankAccountId");
            var bankAccountId = ScenarioContext.Current.Get <Guid>("bankAccountId");

            var data = new SetCurrentPlayerBankAccountData
            {
                PlayerBankAccountId = bankAccountId
            };

            var result = AdminApiProxy.SetCurrentBankAccountInPlayerManager(data);

            result.Should().NotBeNull();
            result.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK);
        }
Пример #3
0
        public void SetCurrent(PlayerBankAccountId playerBankAccountId)
        {
            using (var scope = CustomTransactionScope.GetTransactionScope())
            {
                var setCurrentPlayerBankAccountCommand = new SetCurrentPlayerBankAccountData
                {
                    PlayerBankAccountId = playerBankAccountId
                };

                var validationResult = new SetCurrentPlayerBankAccountValidator(_repository).Validate(setCurrentPlayerBankAccountCommand);

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

                var bankAccount = _repository.PlayerBankAccounts
                                  .Include(x => x.Player.CurrentBankAccount)
                                  .Include(x => x.Player.Brand)
                                  .Include(x => x.Bank)
                                  .Single(x => x.Id == setCurrentPlayerBankAccountCommand.PlayerBankAccountId);

                bankAccount.Player.CurrentBankAccount.IsCurrent = false;
                bankAccount.Player.CurrentBankAccount           = bankAccount;
                bankAccount.IsCurrent = true;

                _repository.SaveChanges();

                _eventBus.Publish(new PlayerBankAccountCurrentSet(
                                      bankAccount.Player.Id,
                                      bankAccount.Id,
                                      bankAccount.AccountNumber)
                {
                    EventCreated = DateTimeOffset.Now.ToBrandOffset(bankAccount.Player.Brand.TimezoneId),
                });

                scope.Complete();
            }
        }
Пример #4
0
        public ValidationResult ValidateThatPlayerBankAccountCanBeSet(SetCurrentPlayerBankAccountData data)
        {
            var validator = new SetCurrentPlayerBankAccountValidator(_repository);

            return(validator.Validate(data));
        }
Пример #5
0
 public HttpResponseMessage SetCurrentBankAccountInPlayerManager(SetCurrentPlayerBankAccountData request)
 {
     return(WebClient.SecurePostAsJson <SetCurrentPlayerBankAccountData, HttpResponseMessage>(Token, _url + AdminApiRoutes.SetCurrentBankAccountInPlayerManager, request));
 }