Example #1
0
        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 });
            }
        }