Exemple #1
0
        public Account OpenAccount(Customer customer)
        {
            if(customer==null)
            {
                throw new ArgumentNullException();
            }

            if(!CheckCredit(customer))
            {
                throw new BadCreditException();
            }

            var account = new Account(customer);
            _accounts.Add(account);
            return account;
        }
 public ActionResult Create(string firstName, string lastName, int? ficoScore)
 {
     var bank = BankRepository.GetBank();
     var auditLog = new AuditLog(bank);
     if (ficoScore == null) throw new NotSupportedException();
     var customer = new Customer(firstName, lastName, ficoScore.Value);
     var creditPassed = bank.CheckCredit(customer);
     if (creditPassed)
     {
         var newCustomer = CustomerRepository.CreateCustomer(customer);
         var account = bank.OpenAccount(newCustomer);
         var newAccount = AccountRepository.CreateAccount(account);
         return RedirectToAction("View", "BankAccount", newCustomer.Id);
     }
     AuditLogRepository.WriteEntries(auditLog);
     return View();
 }
 public void Save(Customer newCustomer)
 {
     throw new NotImplementedException();
 }
 public Customer CreateCustomer(Customer newCustomerToSave)
 {
     _customers.Add(newCustomerToSave);
     return newCustomerToSave;
 }
Exemple #5
0
 public Account(Customer customer)
 {
     _holder = customer;
     Balance = 0;
 }
Exemple #6
0
 public bool CheckCredit(Customer customer)
 {
     return customer.FicoScore >= _minimumCreditScore;
 }