コード例 #1
0
        public void Verify(PlayerBankAccountId playerBankAccountId, string remarks)
        {
            var validationResult =
                new VerifyPlayerBankAccountValidator(_repository).Validate(new VerifyPlayerBankAccountData
            {
                Id = playerBankAccountId
            });

            if (!validationResult.IsValid)
            {
                throw new RegoException(validationResult.Errors.First().ErrorMessage);
            }

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

            using (var scope = CustomTransactionScope.GetTransactionScope())
            {
                bankAccount.Status     = BankAccountStatus.Verified;
                bankAccount.Remarks    = remarks;
                bankAccount.VerifiedBy = _actorInfoProvider.Actor.UserName;

                bankAccount.Verified = DateTimeOffset.Now.ToBrandOffset(bankAccount.Player.Brand.TimezoneId);

                _repository.SaveChanges();

                _eventBus.Publish(new PlayerBankAccountVerified(
                                      bankAccount.Player.Id,
                                      bankAccount.Id,
                                      bankAccount.AccountNumber,
                                      bankAccount.Remarks)
                {
                    EventCreated = bankAccount.Verified.Value,
                });

                scope.Complete();
            }

            _messageService.TrySendPlayerMessage(
                bankAccount.Player.Id,
                MessageType.PlayerBankAccountApproved,
                MessageDeliveryMethod.Email,
                new PlayerBankAccountApprovedModel());
        }
コード例 #2
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();
            }
        }
コード例 #3
0
 public AFT.RegoV2.Core.Payment.Data.PlayerBankAccount GetPlayerBankAccountForSetCurrent(PlayerBankAccountId id)
 {
     return(_repository.PlayerBankAccounts.Include(x => x.Player).SingleOrDefault(x => x.Id == id));
 }