// GET: History // handle if user gets here in other ways public ActionResult History() { // Create BankLogic objects and check session BankLogic bankLogic = new BankLogic(); string SessionSSN = bankLogic.CheckSessionState(); // Check if session is active, redirect to index if (!string.IsNullOrEmpty(SessionSSN)) { List<string> getAccounts = bankLogic.GetAccountsById(SessionSSN); AccountList AccountList = new AccountList(); // Get accounts to display in index view foreach (var account in getAccounts) { AccountList.account.Add(account.ToString()); } return this.RedirectToAction("Index", "Bank", new { error = SessionSSN }); } else { // Redirect to error page if session is invalid string loginStatus = "Session is invalid, please try again."; return this.RedirectToAction("Error", "Bank", new { error = loginStatus }); } }
// GET: Withdrawal // handle if user gets here in other ways public ActionResult Withdrawal() { // Create BankLogic objects and check session BankLogic bankLogic = new BankLogic(); string sessionState = bankLogic.CheckSessionState(); // Check if session is active then redirect to index if (!string.IsNullOrEmpty(sessionState)) { List<string> getAccounts = bankLogic.GetAccountsById(sessionState); AccountList AccountList = new AccountList(); foreach (var account in getAccounts) { AccountList.account.Add(account.ToString()); } return this.RedirectToAction("Index", "Bank", new { error = sessionState }); } else { // Redirect to error page if session is invalid string loginStatus = "Session is invalid, please try again."; return this.RedirectToAction("Error", "Bank", new { error = loginStatus }); } }
public ActionResult Index(string SSN, string pin) { // Create BankLogic and Account List obects BankLogic bankLogic = new BankLogic(); AccountList AccountList = new AccountList(); List<string> loginStatus = new List<string>(); // Check log in credentials if (!string.IsNullOrEmpty(SSN) && !string.IsNullOrEmpty(pin)) { loginStatus = bankLogic.LogIn(SSN, pin); // Check log in status if (loginStatus[0] == "Ok") { // Get list of accounts List<string> getAccounts = bankLogic.GetAccountsById(SSN); foreach (var account in getAccounts) { AccountList.account.Add(account.ToString()); } return View(AccountList); } else { return this.RedirectToAction("Error", "Bank", new { error = loginStatus[1] }); } } else { return this.RedirectToAction("Error", "Bank", new { error = loginStatus }); } }
// GET: Bank // handle if user gets here in other ways public ActionResult Index(string error) { // Create BankLogic and Account List obects BankLogic bankLogic = new BankLogic(); string loginStatus = null; string sessionState = bankLogic.CheckSessionState(); AccountList AccountList = new AccountList(); // Check if user was redirected if (!string.IsNullOrEmpty(error)) { List<string> getAccounts = bankLogic.GetAccountsById(error); // Check if user has bankaccounts, else redirect to error page if (getAccounts[0] == "false") { return this.RedirectToAction("Error", "Bank", new { error = getAccounts[1] }); } else { // Get list of accounts foreach (var account in getAccounts) { AccountList.account.Add(account.ToString()); } } return View(AccountList); } // Check if session is active else if (!string.IsNullOrEmpty(sessionState)) { List<string> getAccounts = bankLogic.GetAccountsById(sessionState); // Check if user has bankaccounts, else redirect to error page if (getAccounts[0] == "false") { return this.RedirectToAction("Error", "Bank", new { error = getAccounts[1] }); } else { // Get list of accounts foreach (var account in getAccounts) { AccountList.account.Add(account.ToString()); } } return View(AccountList); } // Handle unexpected errors else { if (string.IsNullOrEmpty(loginStatus)) { loginStatus = "Unhandled error"; } return this.RedirectToAction("Error", "Bank", new { error = loginStatus }); } }