Esempio n. 1
0
 public ActionResult SubcategoryEdit(ModifySubcategoryViewModel cur)
 {
     if (ModelState.IsValid)
     {
         var parentcate = (from f in db.Categories
                           where f.Name == cur.SelectCategory
                           select f).FirstOrDefault();
         var toedit = new Subcategory
         {
             Id         = cur.SubcategoryId,
             Name       = cur.Name,
             Slug       = cur.Slug,
             CategoryId = parentcate.Id,
             Hidden     = false,
         };
         if (TypeLogic.AdminSubcategoryModify(toedit, parentcate.Id))
         {
             return(RedirectToAction("CategoryDetail", new { cateID = parentcate.Id }));
         }
     }
     ViewData["cates"] = (from f in db.Categories
                          where f.Hidden == false
                          select f.Name).ToList();
     TempData["error"] = "Invalid Edition of the Subcategory. The name or slug already exists for the same category.";
     return(View(cur));
 }
Esempio n. 2
0
        public ActionResult SubcategoryEdit(int?subcateID)
        {
            if (subcateID == null)
            {
                return(HttpNotFound());
            }

            //authorize admin
            if (acl.AuthorizeAdmin(User.Identity.GetUserId()) == false)
            {
                return(HttpNotFound());
            }


            //check legal
            if (acl.CheckSubcategoryLegal((int)subcateID) == false)
            {
                return(HttpNotFound());
            }

            var subcate    = db.Subcategories.Find((int)subcateID);
            var parentcate = db.Categories.Find(subcate.CategoryId);
            var subtoedit  = new ModifySubcategoryViewModel
            {
                SubcategoryId  = subcate.Id,
                SelectCategory = parentcate.Name,
                Name           = subcate.Name,
                Slug           = subcate.Slug
            };

            ViewData["cates"] = (from f in db.Categories
                                 where f.Hidden == false
                                 select f.Name).ToList();
            return(View(subtoedit));
        }