예제 #1
0
        public void Consume(BankAccountEdited message)
        {
            var bankAccount = _playerRepository.BankAccounts
                              .Single(o => o.Id == message.Id);

            bankAccount.AccountId         = message.AccountId;
            bankAccount.BankId            = message.BankId;
            bankAccount.BankAccountStatus = message.BankAccountStatus;

            _playerRepository.BankAccounts.AddOrUpdate(bankAccount);
            _playerRepository.SaveChanges();
        }
예제 #2
0
        public void Edit(EditBankAccountData data)
        {
            using (var scope = CustomTransactionScope.GetTransactionScope())
            {
                var validationResult = new EditBankAccountValidator(_repository, _brandRepository).Validate(data);

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

                var bankAccount = _repository.BankAccounts
                                  .Include(x => x.Bank.Brand)
                                  .Single(x => x.Id == data.Id);

                bankAccount.Bank          = _repository.Banks.Single(x => x.Id == data.Bank);
                bankAccount.CurrencyCode  = data.Currency;
                bankAccount.AccountId     = data.AccountId;
                bankAccount.AccountName   = data.AccountName;
                bankAccount.AccountNumber = data.AccountNumber;
                bankAccount.AccountType   = _repository.BankAccountTypes.Single(x => x.Id == data.AccountType);
                bankAccount.Province      = data.Province;
                bankAccount.Branch        = data.Branch;
                bankAccount.Remarks       = data.Remarks;
                bankAccount.Updated       = DateTimeOffset.Now.ToBrandOffset(bankAccount.Bank.Brand.TimezoneId);
                bankAccount.UpdatedBy     = _actorInfoProvider.Actor.UserName;

                _repository.SaveChanges();

                var bankAccountEdited = new BankAccountEdited
                {
                    Id                = bankAccount.Id,
                    AccountId         = bankAccount.AccountId,
                    Name              = bankAccount.AccountName,
                    Number            = bankAccount.AccountNumber,
                    BankId            = bankAccount.Bank.Id,
                    UpdatedBy         = bankAccount.UpdatedBy,
                    UpdatedDate       = bankAccount.Updated.Value,
                    BankAccountStatus = bankAccount.Status,
                    EventCreated      = bankAccount.Updated.Value,
                };
                _eventBus.Publish(bankAccountEdited);

                scope.Complete();
            }
        }
 public void Consume(BankAccountEdited message)
 {
     _eventHandlers.Handle(message);
 }
예제 #4
0
 public void Handle(BankAccountEdited @event)
 {
     AddActivityLog(AdminActivityLogCategory.BankAccount, @event);
 }
예제 #5
0
        public void SaveChanges(
            EditBankAccountData bankAccountData,
            byte[] idFrontImage,
            byte[] idBackImage,
            byte[] atmCardImage
            )
        {
            //Server Validation

            var frontImageId   = SaveFile(bankAccountData.IdFrontImage, idFrontImage, bankAccountData.Id);
            var backImageId    = SaveFile(bankAccountData.IdBackImage, idBackImage, bankAccountData.Id);
            var atmCardImageId = SaveFile(bankAccountData.AtmCardImage, atmCardImage, bankAccountData.Id);

            using (var scope = CustomTransactionScope.GetTransactionScope())
            {
                var bankAccount = _repository.BankAccounts
                                  .Include(x => x.Bank.Brand)
                                  .Single(x => x.Id == bankAccountData.Id);

                bankAccount.Bank          = _repository.Banks.Single(x => x.Id == bankAccountData.Bank);
                bankAccount.CurrencyCode  = bankAccountData.Currency;
                bankAccount.AccountId     = bankAccountData.AccountId;
                bankAccount.AccountName   = bankAccountData.AccountName;
                bankAccount.AccountNumber = bankAccountData.AccountNumber;
                //bankAccount.AccountType = bankAccountData.AccountType;
                bankAccount.AccountType     = _repository.BankAccountTypes.Single(x => x.Id == bankAccountData.AccountType);
                bankAccount.Province        = bankAccountData.Province;
                bankAccount.Branch          = bankAccountData.Branch;
                bankAccount.Remarks         = bankAccountData.Remarks;
                bankAccount.SupplierName    = bankAccountData.SupplierName;
                bankAccount.ContactNumber   = bankAccountData.ContactNumber;
                bankAccount.USBCode         = bankAccountData.USBCode;
                bankAccount.PurchasedDate   = DateTime.Parse(bankAccountData.PurchasedDate);
                bankAccount.UtilizationDate = DateTime.Parse(bankAccountData.UtilizationDate);
                bankAccount.ExpirationDate  = DateTime.Parse(bankAccountData.ExpirationDate);
                //bankAccount.IdFrontImage = frontImageId;
                //bankAccount.IdBackImage = backImageId;
                //bankAccount.ATMCardImage = atmCardImageId;
                bankAccount.Updated   = DateTimeOffset.Now.ToBrandOffset(bankAccount.Bank.Brand.TimezoneId);
                bankAccount.UpdatedBy = _actorInfoProvider.Actor.UserName;

                if (frontImageId != null)
                {
                    bankAccount.IdFrontImage = frontImageId;
                }
                if (backImageId != null)
                {
                    bankAccount.IdBackImage = backImageId;
                }
                if (atmCardImageId != null)
                {
                    bankAccount.ATMCardImage = atmCardImageId;
                }

                _repository.SaveChanges();

                var bankAccountChanged = new BankAccountEdited
                {
                    Id                = bankAccount.Id,
                    AccountId         = bankAccount.AccountId,
                    Name              = bankAccount.AccountName,
                    Number            = bankAccount.AccountNumber,
                    BankId            = bankAccount.Bank.Id,
                    UpdatedBy         = bankAccount.UpdatedBy,
                    UpdatedDate       = bankAccount.Updated.Value,
                    BankAccountStatus = bankAccount.Status,
                    EventCreated      = bankAccount.Updated.Value,
                    Remarks           = bankAccount.Remarks
                };

                _eventBus.Publish(bankAccountChanged);

                scope.Complete();
            }
        }