예제 #1
0
        // 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");
            }
        }
예제 #2
0
        //// GET: Customer 
        //public ActionResult GetCustomers()
        //{
        //    // If logged in
        //    bool state = (bool)Session["loggedInState"];
        //    if (state == true)
        //    {
        //        // Creates models
        //        var addressModel = new AddressModel();
        //        var customerModel = new CustomerModel();
        //        // Gets the complete list
        //        var customerList = customerModel.ListCustomers();
        //        // Attaches associated address to customer
        //        foreach (var customer in customerList)
        //        {
        //            Address address = null;
        //            if (customer.Address_ID != 0)
        //            {
        //                address = addressModel.SearchAddress(customer.Address_ID);
        //            }
        //            // Appends object to address
        //            customer.Address = address;
        //        }
        //        // Return the CustomerList
        //        return View(customerList);
        //    }
        //    else
        //    {
        //        return Redirect("/403.html");
        //    }
        //}
        // Creates a new customer
        public int create(String name, int addressID)
        {
            // Establishes models
            CustomerModel customerModel = new CustomerModel();

            // Holds object placeholders
            Customer newCustomer = new Customer();

            // Stored details for the customer
            newCustomer.Name = name;
            newCustomer.Address_ID = addressID;

            // Creates the customer
            int customerID = customerModel.CreateCustomer(newCustomer);

            // Return created department to view
            return customerID;
        }
예제 #3
0
        // 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");
            }
        }
예제 #4
0
        // Allows deleting of customer
        public ActionResult delete()
        {
            // Null handling
            if (Session["loggedInState"] == null)
            {
                return Redirect("/403.html");
            }

            // Checks if logged in
            bool state = (bool)Session["loggedInState"];
            if (state == true)
            {
                int customerID = int.Parse(RouteData.Values["id"].ToString());

                // Establishes account model
                CustomerModel customerModel = new CustomerModel();

                // Deletes the account, and contact from the database using the ID
                customerModel.DeleteCustomer(customerID);

                // Return to the account page
                return Redirect("/Customer/Customer");
            }
            else
            {
                // If not logged in
                return Redirect("/login.html");
            }
        }
예제 #5
0
        // View individual customer details
        public ActionResult editPage()
        {
            // Null handling
            if (Session["loggedInState"] == null)
            {
                return Redirect("/403.html");
            }

            // Get the ID requested
            int id = int.Parse(Url.RequestContext.RouteData.Values["id"].ToString());

            CustomerModel customerModel = new CustomerModel();
            Customer customer = customerModel.SearchCustomers(id);

            // If logged in
            bool state = (bool)Session["loggedInState"];
            if (state == true)
            {
                // Return customer object
                return View(customer);
            }
            else
            {
                // If not logged in
                return Redirect("/login.html");
            }
        }
예제 #6
0
        // View individual customer details
        public ActionResult view()
        {
            // Null handling
            if (Session["loggedInState"] == null)
            {
                return Redirect("/403.html");
            }

            // If logged in
            bool state = (bool)Session["loggedInState"];
            if (state == true)
            {
                // Establishes models
                AccountModel clientModel = new AccountModel();
                CustomerModel customerModel = new CustomerModel();
                List<Account> accountList = new List<Account>();

                // Get the ID requested
                int theID = int.Parse(Url.RequestContext.RouteData.Values["id"].ToString());

                Customer customer = new Customer();
                customer.ID = theID;

                accountList = clientModel.SearchAccounts(customer);

                foreach(var account in accountList)
                {
                    account.Customer = customerModel.SearchCustomers(account.CustomerID);
                }

                return View(accountList);
            }
            else
            {
                // If not logged in
                return Redirect("/login.html");
            }
        }
예제 #7
0
 public ActionResult createCustomer()
 {
     if (Session["loggedInState"] == null)
     {
         return Redirect("/403.html");
     }
     else
     {
         int id = int.Parse(Request.Form["newAddress"]);
         String name = Request.Form["newClientName"];
         Customer client = new Customer();
         client.Name = name;
         client.Address_ID = id;
         var cm = new CustomerModel();
         cm.CreateCustomer(client);
         return Redirect("Customer");
     }
 }
예제 #8
0
        // Allows editing of a customer
        public ActionResult edit()
        {
            // Null handling
            if (Session["loggedInState"] == null)
            {
                return Redirect("/403.html");
            }

            // Checks if logged in
            bool state = (bool)Session["loggedInState"];
            if (state == true)
            {
                // Creates an department placeholder
                Customer customer = new Customer();

                // Establish customer model
                CustomerModel customerModel = new CustomerModel();

                // Setup address edit
                customer.ID = int.Parse(Request.Form["id"]);
                customer.Address_ID = int.Parse(Request.Form["addressID"]);
                customer.Name = Request.Form["customerName"];

                // Conduct edit
                customerModel.EditCustomer(customer);

                // Passes back to the view
                return Redirect("/Customer/Customer");
            }
            else
            {
                // If not logged in
                return Redirect("/login.html");
            }
        }
예제 #9
0
        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");
            }
        }
예제 #10
0
 public ActionResult Edit()
 {
     if (Session["loggedInState"] == null)
     {
         return Redirect("/403.html");
     }
     bool state = (bool)Session["loggedInState"];
     if (state == true)
     {
         // Get the ID as a parameter
         var p = int.Parse(Url.RequestContext.RouteData.Values["id"].ToString());
         // Create a new CustomerModel object
         var cm = new CustomerModel();
         // Call the method to search for a Customer with an ID matching the value passed in
         var c = cm.SearchCustomers(p);
         // Return the Customer information
         return View(c);
     }
     else
     {
         return Redirect("/login.html");
     }
 }
예제 #11
0
 public ActionResult deleteThis()
 {
     CustomerModel deleteMe = new CustomerModel();
     deleteMe.DeleteCustomer(int.Parse(Request.Form["ID"]));
     return Redirect("Customer");
 }
예제 #12
0
 public ActionResult Delete()
 {
     //If there is no valid session, return forbidden
     if (Session["loggedInState"] == null)
     {
         return Redirect("/403.html");
     }
     else
     {
         CustomerModel cm = new CustomerModel();
         Customer c = cm.SearchCustomers(int.Parse(RouteData.Values["id"].ToString()));
         return View(c);
     }
 }
예제 #13
0
 // 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);
     }
 }