public IActionResult Deposit() { var session = Request.Cookies["SESSION_ID"]; Database Test_Auth = new Database(); ProfileInterface Verified = Test_Auth.VerifySession(session); //Check if Verified is a TellerProfile type object, this means the session is valid if (Verified?.profile_type != ProfileInterface.ProfileType.TELLER && Verified?.profile_type != ProfileInterface.ProfileType.ADMIN) { return(View("Denied")); } var my_interface = Test_Auth.VerifySession(session); var customer = Test_Auth.getCurrentCustomer(session); if (customer == my_interface.username) { return(RedirectToAction("Dashboard", "Teller")); // if you're not helping someone, go back to dashboard } ViewBag.cust = customer; ViewBag.searched = "yes"; if (Verified.profile_type != ProfileInterface.ProfileType.CUSTOMER) { CustomerProfile custprof = new CustomerProfile(customer); ViewBag.Accounts = custprof.ListAccounts(); } else { ViewBag.Accounts = ((CustomerProfile)my_interface).ListAccounts(); } if (Request.HasFormContentType) { if (!String.IsNullOrEmpty(Request.Form["username"])) { ViewBag.cust = customer; ViewBag.searched = "yes"; ViewBag.Accounts = ((TellerProfile)my_interface).ListAccounts(customer); } //At this point there should be an acctFrom in the title. this is just a sanity check //To make sure we don't run this on page load. if (!String.IsNullOrEmpty(Request.Form["acctTo"])) { string cashorcheck = Request.Form["depType"]; if (my_interface.profile_type == ProfileInterface.ProfileType.TELLER) { ((TellerProfile)my_interface)?.Deposit(Convert.ToInt32(Request.Form["acctTo"]), Convert.ToDecimal(Request.Form["amount"]), cashorcheck); } if (my_interface.profile_type == ProfileInterface.ProfileType.ADMIN) { (new TellerProfile()).Deposit(Convert.ToInt32(Request.Form["acctTo"]), Convert.ToDecimal(Request.Form["amount"]), cashorcheck); } ViewBag.To = Request.Form["acctTo"]; ViewBag.amt = Request.Form["amount"]; ViewBag.From = null; ViewBag.type = "Deposit"; return(View("Transaction")); } } ViewBag.User = my_interface.username; return(View()); }
public IActionResult Bill() { CustomerProfile custprof = null; var session = Request.Cookies["SESSION_ID"]; Database Test_Auth = new Database(); ProfileInterface Verified = Test_Auth.VerifySession(session); //Check if Verified is a TellerProfile type object, this means the session is valid if (Verified?.profile_type != ProfileInterface.ProfileType.CUSTOMER && Verified?.profile_type != ProfileInterface.ProfileType.TELLER && Verified?.profile_type != ProfileInterface.ProfileType.ADMIN) { return(View("Denied")); } var my_interface = Test_Auth.VerifySession(session); var customer = Test_Auth.getCurrentCustomer(session); ViewBag.cust = customer; if (Verified.profile_type != ProfileInterface.ProfileType.CUSTOMER) { custprof = new CustomerProfile(customer); ViewBag.Accounts = custprof.ListAccounts(); } else { ViewBag.Accounts = ((CustomerProfile)my_interface).ListAccounts(); } ViewBag.searched = "yes"; if (Request.HasFormContentType) { if (!String.IsNullOrEmpty(Request.Form["username"])) { ViewBag.cust = customer; ViewBag.searched = "yes"; if (Verified.profile_type != ProfileInterface.ProfileType.CUSTOMER) { custprof = new CustomerProfile(customer); ViewBag.Accounts = custprof.ListAccounts(); } else { ViewBag.Accounts = ((CustomerProfile)my_interface).ListAccounts(); } } //At this point there should be an acctFrom in the title. this is just a sanity check //To make sure we don't run this on page load. if (!String.IsNullOrEmpty(Request.Form["acctTo"])) { Test_Auth.WithdrawAmt(Convert.ToInt32(Request.Form["acctFrom"]), Convert.ToDecimal(Request.Form["amount"]), "Bill Pay"); Test_Auth.WithdrawAmt(Convert.ToInt32(Request.Form["acctTo"]), Convert.ToDecimal(Request.Form["amount"]), "Bill Pay"); ViewBag.To = Request.Form["acctTo"]; ViewBag.amt = Request.Form["amount"]; ViewBag.From = Request.Form["acctFrom"]; ViewBag.type = "Bill Pay"; return(View("Transaction")); } } ViewBag.User = my_interface.username; return(View()); }