예제 #1
0
        public ActionResult SubCatDetails(SubCategoryDetail sc)
        {
            if (!isAdmin())
            {
                return(RedirectToAction("LogIn", "Main"));
            }
            if (ModelState.IsValid)
            {
                SubCategory updated = new SubCategory()
                {
                    ID    = sc.ID,
                    name  = sc.name,
                    catId = sc.categoryId,
                };
                Customer admin   = (Customer)Session["loggedInUser"];
                var      adminid = admin.id;
                bool     result  = _categoryBLL.update(adminid, updated);

                sc.categoryList = _categoryBLL.getAll(null).Select(c => new SelectListItem {
                    Value = c.ID.ToString(), Text = c.name
                }).ToList();

                if (result)
                {
                    return(Json(new { success = true, message = "Subkategorien ble endret", redirect = "/Category/ListSubCategories" }));
                }
                return(Json(new { success = false, message = "Noe gikk galt, prøv igjen senenere" }));
            }
            return(Json(new { success = false, message = "feil i validering" }));
        }