public ActionResult ViewInfo() { //If there is no valid session, return forbidden if (Session["loggedInState"] == null) { return(Redirect("/403.html")); } else { // Create a new AddressModel object var addressModel = new AddressModel(); // Create a CustomerModel object var customerModel = new CustomerModel(); // Call the method to get the list var customerList = customerModel.ListCustomers(); // Get the ID requested var p = int.Parse(Url.RequestContext.RouteData.Values["id"].ToString()); foreach (var customer in customerList) { if (customer.ID == p) { Address address = addressModel.SearchAddress(customer.Address_ID); customer.Address = address; return(View(customer)); } } // No match found! Change the page later... return(Redirect("/404.html")); } }
public ActionResult view() { // Null handling if (Session["loggedInState"] == null) { return(Redirect("/403.html")); } // Checks if logged in bool state = (bool)Session["loggedInState"]; if (state == true) { // Creates an address model AddressModel addressModel = new AddressModel(); // Get the ID as a parameter var id = int.Parse(Url.RequestContext.RouteData.Values["id"].ToString()); // Holds the new address Address theAddress = addressModel.SearchAddress(id); // Passes back to the view with address return(View(theAddress)); } else { // If not logged in return(Redirect("/login.html")); } }
// Returns a list of all banks public ActionResult view() { // Null handling if (Session["loggedInState"] == null) { return(Redirect("/403.html")); } // If logged in bool state = (bool)Session["loggedInState"]; if (state == true) { // Creates models var bankModel = new BankingModel(); var addressModel = new AddressModel(); // Gets the complete list var bl = bankModel.ListBanking(); if (bl.Count != 0) { // Attaches associated department / role to employee foreach (var bank in bl) { // Acquires, and adds the bank address Address address = null; if (bank.Address_ID != 0) { address = addressModel.SearchAddress(bank.Address_ID); } // Appends object to bank bank.Address = address; } // Returns the list return(View(bl)); } else { return(Redirect("/403.html")); } } else { // If not logged in return(Redirect("/login.html")); } }
public ActionResult editPage() { // Null handling if (Session["loggedInState"] == null) { return(Redirect("/403.html")); } else { // Get the ID as a parameter var id = int.Parse(Url.RequestContext.RouteData.Values["id"].ToString()); AddressModel addressModel = new AddressModel(); Address address = addressModel.SearchAddress(id); return(View(address)); } }
// Gets list of customers public ActionResult Customer() { // Null handling if (Session["loggedInState"] == null) { return(Redirect("/403.html")); } // If logged in bool state = (bool)Session["loggedInState"]; if (state == true) { // Establishes models CustomerModel customerModel = new CustomerModel(); AddressModel addressModel = new AddressModel(); // Call the method to get the list var customerList = customerModel.ListCustomers(); // For each customer in the list foreach (var customer in customerList) { // Find associated address Address address = addressModel.SearchAddress(customer.Address_ID); // Append address to customer object customer.Address = address; } // Returns the customer list return(View(customerList)); } else { // If not logged in return(Redirect("/login.html")); } }
// Function to get a list of all customers public ActionResult Customer() { //If there is no valid session, return forbidden if (Session["loggedInState"] == null) { return(Redirect("/403.html")); } else { // Create a new AddressModel object var addressModel = new AddressModel(); // Create a CustomerModel object var customerModel = new CustomerModel(); // Call the method to get the list var customerList = customerModel.ListCustomers(); foreach (var customer in customerList) { Address address = addressModel.SearchAddress(customer.Address_ID); customer.Address = address; } // Return the CustomerList return(View(customerList)); } }