示例#1
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");
            }
        }