// GET: Account/Close/5 public ActionResult Close(int id) { string userEmail = User.Identity.Name; string returnUrl; if (userEmail != null) { var account = _accountBl.GetAccount(id); if (account.Balance == 0) { ViewBag.AccountClosed = _accountBl.CloseAccount(account); } else { ViewBag.AccountClosed = false; if (account.AccountType == "TDC") { var tdcInfo = _accountBl.ViewTdcAdditional(id); ViewBag.MaturityDate = (tdcInfo.MaturityDate).Date; } } return(View(account)); } else { returnUrl = Url.Content("~/Home/Index"); return(LocalRedirect(returnUrl)); } }
}//end handleOpenAccount() #endregion #region 2.HandleCloseAccount() public static void HandleCloseAccount() { if (AccountsExisted()) { DisplayAccounts(customer.CustomerId); Console.WriteLine("Enter Account number you want to close"); string accountNo = Console.ReadLine(); //error not deal accountbl.CloseAccount(Convert.ToInt32(accountNo)); // Conver dealing with null, and out put 0. Prase does not deal with null value. } else { Console.WriteLine("No exisiting accounts"); } }
public void ClosedAccountDepositAndWithdrawTest() { AccountBL accountbl = new AccountBL(); decimal expectedCheckingBalance = 0; decimal expectedBusinessBalance = 0; decimal expectedLoanBalance = 0; decimal expectedTermdepositBalance = 0; bool expectedStatus = false; IAccount checkingAccountInfo = new CheckingAccount() { Accountno = accountbl.GenerateAccountno(), Balance = accountbl.GetBalance(), CustomerId = 1, AccountStatus = true }; checkingAccountInfo.AccountType = accountbl.GetAcountType(checkingAccountInfo); checkingAccountInfo.Interestrate = accountbl.GetIntrestrate(checkingAccountInfo); accountbl.OpenAccount(checkingAccountInfo); accountbl.CloseAccount(checkingAccountInfo); accountbl.Deposit(checkingAccountInfo, 1000m); //good test accountbl.Deposit(checkingAccountInfo, 2000m); //good test accountbl.Deposit(checkingAccountInfo, 1.0m); //good test accountbl.Deposit(checkingAccountInfo, -1000m); //bad test accountbl.Deposit(checkingAccountInfo, -1m); //bad test accountbl.Deposit(checkingAccountInfo, -1.0m); //bad test accountbl.Deposit(checkingAccountInfo, 0m); //bad test accountbl.Withdraw(checkingAccountInfo, 900m); //good test accountbl.Withdraw(checkingAccountInfo, 100m); //good test accountbl.Withdraw(checkingAccountInfo, 1.0m); //good test accountbl.Withdraw(checkingAccountInfo, -1000m); //bad test accountbl.Withdraw(checkingAccountInfo, -1m); //bad test accountbl.Withdraw(checkingAccountInfo, -1.0m); //bad test accountbl.Withdraw(checkingAccountInfo, 0m); //bad test Assert.AreEqual(expectedStatus, checkingAccountInfo.AccountStatus); Assert.AreEqual(expectedCheckingBalance, checkingAccountInfo.Balance); IAccount businessAccountInfo = new BusinessAccount() { Accountno = accountbl.GenerateAccountno(), Balance = accountbl.GetBalance(), CustomerId = 1, AccountStatus = true, }; businessAccountInfo.AccountType = accountbl.GetAcountType(businessAccountInfo); businessAccountInfo.Interestrate = accountbl.GetIntrestrate(businessAccountInfo); accountbl.OpenAccount(businessAccountInfo); accountbl.CloseAccount(businessAccountInfo); accountbl.Deposit(businessAccountInfo, 2000m); //good test accountbl.Deposit(businessAccountInfo, 2000m); //good test accountbl.Deposit(businessAccountInfo, 1.0m); //good test accountbl.Deposit(businessAccountInfo, -1000m); //bad test accountbl.Deposit(businessAccountInfo, -1m); //bad test accountbl.Deposit(businessAccountInfo, -1.0m); //bad test accountbl.Deposit(businessAccountInfo, 0m); //bad test Assert.AreEqual(expectedStatus, businessAccountInfo.AccountStatus); Assert.AreEqual(expectedBusinessBalance, businessAccountInfo.Balance);//output 3000 IAccount loanAccountInfo = new Loan(0) { Accountno = accountbl.GenerateAccountno(), Balance = accountbl.GetBalance(), CustomerId = 1, AccountStatus = true }; loanAccountInfo.Interestrate = accountbl.GetIntrestrate(loanAccountInfo); accountbl.OpenAccount(loanAccountInfo); accountbl.CloseAccount(loanAccountInfo); accountbl.Deposit(loanAccountInfo, 2000m); //good test accountbl.Deposit(loanAccountInfo, 2000m); //good test accountbl.Deposit(loanAccountInfo, 1.0m); //good test accountbl.Deposit(loanAccountInfo, -1000m); //bad test accountbl.Deposit(loanAccountInfo, -1m); //bad test accountbl.Deposit(loanAccountInfo, -1.0m); //bad test accountbl.Deposit(loanAccountInfo, 0m); //bad test Assert.AreEqual(expectedStatus, loanAccountInfo.AccountStatus); Assert.AreEqual(expectedLoanBalance, loanAccountInfo.Balance); IAccount termdepositAccountInfo = new TermDeposit(0) { Accountno = accountbl.GenerateAccountno(), Balance = accountbl.GetBalance(), CustomerId = 1, AccountStatus = true }; accountbl.OpenAccount(termdepositAccountInfo); accountbl.CloseAccount(termdepositAccountInfo); accountbl.Deposit(termdepositAccountInfo, 2000m); //good test accountbl.Deposit(termdepositAccountInfo, 2000m); //good test accountbl.Deposit(termdepositAccountInfo, 1.0m); //good test accountbl.Deposit(termdepositAccountInfo, -1000m); //bad test accountbl.Deposit(termdepositAccountInfo, -1m); //bad test accountbl.Deposit(termdepositAccountInfo, -1.0m); //bad test accountbl.Deposit(termdepositAccountInfo, 0m); //bad test Assert.AreEqual(expectedStatus, termdepositAccountInfo.AccountStatus); Assert.AreEqual(expectedTermdepositBalance, termdepositAccountInfo.Balance); }