// Gets all transactions public ActionResult Transactions() { // Null handling if (Session["loggedInState"] == null) { return Redirect("/403.html"); } bool state = (bool)Session["loggedInState"]; if (state == true) { // Creates the models var transModel = new TransactionModel(); var orderModel = new OrderModel(); var custModel = new CustomerModel(); var bankModel = new BankingModel(); // Gets the complete list var tl = transModel.ListTransactions(); if (tl.Count != 0) { // Attaches associated order / customer / bank to transaction foreach (var trans in tl) { // Acquires, and adds the order to transaction Order order = null; if (trans.OrderID != 0) { order = orderModel.SearchOrder(trans.OrderID); } // Acquires, and adds the customer to transaction Customer cust = null; if (trans.CustomerID != 0) { cust = custModel.SearchCustomers(trans.CustomerID); } // Acquires, and adds the bank to transaction Bank bank = null; if (trans.BankID != 0) { bank = bankModel.SearchBank(trans.BankID); } } } // Returns the list return View(tl); } 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"); } }
// Creates a bank public int create( String sortCode, int accountNumber) { // Establishes model BankingModel bankModel = new BankingModel(); // Holds the new bank Bank newBank = new Bank(); // Stored details for the bank newBank.SortCode = sortCode; newBank.AccountNumber = accountNumber; // Creates the bank int bankID = bankModel.CreateBank(newBank); // Returns created bank return bankID; }