Esempio n. 1
0
        public PaymentAccountsController(
            CustomerRepository customersRepository,
            ICustomerMarketPlaceRepository customerMarketplacesReporsitory,
            IWorkplaceContext context,
            ISortCodeChecker sortCodeChecker,
            BankAccountUniqChecker bankAccountUniqChecker)
        {
            this.customersRepository             = customersRepository;
            this.serviceClient                   = new ServiceClient();
            this.customerMarketplacesReporsitory = customerMarketplacesReporsitory;

            this.context                = context;
            this.sortCodeChecker        = sortCodeChecker;
            this.bankAccountUniqChecker = bankAccountUniqChecker;
        }
 public PaymentAccountsController(
     DatabaseDataHelper dbHelper,
     CustomerRepository customersRepository,
     IEzbobWorkplaceContext context,
     IMPUniqChecker mpChecker,
     IYodleeAccountChecker yodleeAccountChecker,
     BankAccountUniqChecker bankAccountUniqChecker,
     ISortCodeChecker sortCodeChecker)
 {
     this.dbHelper               = dbHelper;
     this.customersRepository    = customersRepository;
     this.context                = context;
     this.serviceClient          = new ServiceClient();
     this.mpChecker              = mpChecker;
     this.yodleeAccountChecker   = yodleeAccountChecker;
     this.bankAccountUniqChecker = bankAccountUniqChecker;
     this.sortCodeChecker        = sortCodeChecker;
 }
Esempio n. 3
0
        }         // AddAlibabaDefaultBankAccount

        public static int AddBankAccount(this Customer customer, string bankAccount, string sortCode, BankAccountType accountType, BankAccountUniqChecker bankAccountUniqChecker = null, ISortCodeChecker sortCodeChecker = null)
        {
            if (customer == null)               // can happen for Alibaba call only
            {
                ms_oLog.Debug("Customer not specified for adding an account (#{0}, code {1}, type {2}).",
                              bankAccount,
                              sortCode,
                              accountType
                              );

                return(-1);
            }             // if

            if (customer.BankAccounts.Any(a => a.BankAccount == bankAccount && a.SortCode == sortCode))
            {
                ms_oLog.Debug(
                    "Bank account (#{1}, code {2}, type {3}) already exists at customer {0}.",
                    customer.Stringify(),
                    bankAccount,
                    sortCode,
                    accountType
                    );

                return(-2);
            }             // if

            if (sortCodeChecker == null)
            {
                sortCodeChecker = ObjectFactory.GetInstance <ISortCodeChecker>();
            }             // if

            var card = new CardInfo {
                BankAccount = bankAccount,
                SortCode    = sortCode,
                Customer    = customer,
                Type        = accountType,
            };

            try {
                sortCodeChecker.Check(card);
            }
            catch (Exception e) {
                ms_oLog.Debug(
                    e,
                    "Just FYI: exception caught while checking a sort code for new bank account (#{1}, code {2}, type {3}) of customer {0}.",
                    customer.Stringify(),
                    bankAccount,
                    sortCode,
                    accountType
                    );
            }             // try

            ms_oLog.Debug(
                "Adding a new bank account (#{1}, code {2}, type {3}) to customer {0}.",
                customer.Stringify(),
                bankAccount,
                sortCode,
                accountType
                );

            customer.BankAccounts.Add(card);

            if (bankAccountUniqChecker != null)
            {
                try {
                    bankAccountUniqChecker.Check(customer.Id, card);
                } catch (BankAccountIsAlreadyAddedException) {
                    ms_oLog.Debug(
                        "Account already was added by another customer {0} bank: {1} {2} {3}",
                        customer.Id,
                        bankAccount,
                        sortCode,
                        accountType
                        );
                    customer.BlockTakingLoan = true;
                }
            }

            ms_oLog.Debug(
                "Setting a new bank account (#{1}, code {2}, type {3}) as a default one for customer {0}.",
                customer.Stringify(),
                bankAccount,
                sortCode,
                accountType
                );

            customer.SetDefaultCard(card);

            ms_oLog.Debug(
                "Saving to DB a new bank account (#{1}, code {2}, type {3}) for customer {0}.",
                customer.Stringify(),
                bankAccount,
                sortCode,
                accountType
                );

            ObjectFactory.GetInstance <CustomerRepository>().SaveOrUpdate(customer);

            ms_oLog.Debug(
                "A new bank account (#{1}, code {2}, type {3}) has been added to customer {0}. Account id: {4}",
                customer.Stringify(),
                bankAccount,
                sortCode,
                accountType,
                card.Id
                );

            return(card.Id);
        }         // AddBankAccount