コード例 #1
0
        public ActionResult CustomerDetails(CustomerDetail cd)
        {
            if (!isAdmin())
            {
                return RedirectToAction("LogIn", "Main");
            }
            bool b = false;
            bool eouaoae = ModelState.IsValid;
            if (ModelState.IsValid)
            {
                Customer a = (Customer)Session["loggedInUser"];
                Customer c = new Customer();
                c.firstname = cd.firstname;
                c.lastname = cd.lastname;
                c.address = cd.address;
                c.email = cd.email;
                c.phonenumber = cd.phonenumber;
                c.postalarea = cd.postalarea;
                c.postalcode = cd.postalcode;
                b = _customerbll.update(cd.id, c, a.id);
                if (b)
                    return Json(new { success = true, message = "Endringene ble lagret", redirect = "/Customer/ListCustomers/" });
                return Json(new { success = false, message = "Noe gikk galt, endringene ble ikke lagret" }); 
            }
            return Json(new { success = false, message = "Feil i validering" }); 

        }
コード例 #2
0
        public ActionResult CustomerDetails(int id)
        {
            if (!isAdmin())
                return RedirectToAction("LogIn", "Main");

            
            Customer customerDetails = _customerbll.getCustomer(id);

            CustomerDetail custinfo = new CustomerDetail()
            {
                id = customerDetails.id,
                firstname = customerDetails.firstname,
                lastname = customerDetails.lastname,
                email = customerDetails.email,
                address = customerDetails.address,
                postalarea = customerDetails.postalarea,
                postalcode = customerDetails.postalcode,
                phonenumber = customerDetails.phonenumber,
                admin = customerDetails.admin
            };
            return View(custinfo);
        }