Example #1
0
        public ActionResult Address()
        {
            // 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();

                // Holds the new address
                List<Address> addressList = addressModel.GetAddressesList();

                // Passes back to the view with address
                return View(addressList);
            }
            else
            {
                // If not logged in
                return Redirect("/login.html");
            }
        }
Example #2
0
        // Deletes an address
        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 addressID = int.Parse(RouteData.Values["id"].ToString());

                // Establishes address model
                AddressModel addressModel = new AddressModel();

                // Deletes the address from the database using the ID
                addressModel.DeleteAddress(addressID);

                // TODO: Confirm this is the correct return state
                // Return to address page
                return Redirect("../address");
            }
            else
            {
                // If not logged in
                return Redirect("/login.html");
            }
        }
Example #3
0
        // Create address
        public int create(String lineOne, String lineTwo, String lineThree, String lineFour, String lineFive,
                              String state, String county, String country, String postCode)
        {
            // Creates an address model
            AddressModel addressModel = new AddressModel();

            // Holds the new address
            Address newAddress = new Address();

            // Stored details for address
            newAddress.LineOne = lineOne;
            newAddress.LineTwo = lineTwo;
            newAddress.LineThree = lineThree;
            newAddress.LineFour = lineFour;
            newAddress.LineFive = lineFive;
            newAddress.State = state;
            newAddress.County = county;
            newAddress.Country = country;
            newAddress.PostalCode = postCode;

            // Adds the object to the database. Returns address ID
            int addressID = addressModel.CreateAddress(newAddress);

            // Return address ID
            return addressID;
        }
Example #4
0
        // 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");
            }
        }
Example #5
0
        public ActionResult create()
        {
            // Null handling
            if (Session["loggedInState"] == null)
            {
                return Redirect("/403.html");
            }
            else {

                AddressModel addressModel = new AddressModel();
                List<Address> listAddresses = addressModel.GetAddressesList();

                return View(listAddresses);
            }
        }
Example #6
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");
            }
        }
Example #7
0
        // Controller for modification of an address
        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 address placeholder
                var address = new Address();

                // Setup address edit
                address.ID = int.Parse(Request.Form["id"]);
                address.LineOne = Request.Form["lineOne"].ToString();
                address.LineTwo = Request.Form["lineTwo"].ToString();
                address.LineThree = Request.Form["lineThree"].ToString();
                address.LineFour = Request.Form["lineFour"].ToString();
                address.LineFive = Request.Form["lineFive"].ToString();
                address.PostalCode = Request.Form["postalCode"].ToString();
                address.County = Request.Form["county"].ToString();
                address.Country = Request.Form["country"].ToString();

                // Establish address model
                var addressModel = new AddressModel();

                // Conduct edit
                addressModel.EditAddress(address);

                // Passes back to the view
                return View();
            }
            else
            {
                // If not logged in
                return Redirect("/login.html");
            }
        }
Example #8
0
        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");
            }
        }
Example #9
0
        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);

            }
        }
Example #10
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");
            }
        }
Example #11
0
 public ActionResult newCustomer()
 {
     if (Session["loggedInState"] == null)
     {
         return Redirect("/403.html");
     }
     else
     {
         var addresses = new AddressModel();
         var addresslist = addresses.GetAddressesList();
         return View(addresslist);
     }
 }
Example #12
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);
     }
 }