Пример #1
0
 public ActionResult Edit(Category obj)
 {
     if (string.IsNullOrEmpty(obj.Name) || obj.MenuId == Guid.Empty)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
     else
     {
         Category model = CateBLL.GetById(obj.Id);
         if (model == null)
         {
             return(Json(false, JsonRequestBehavior.AllowGet));
         }
         else
         {
             model.Name      = obj.Name;
             model.ShowOrder = obj.ShowOrder;
             model.ParentId  = obj.ParentId;
             model.MenuId    = obj.MenuId;
             UrlRecord url = UrlBLL.Table.FirstOrDefault(o => o.EntityName == "Category" && o.EntityId == obj.Id);
             url.Slug = obj.ValidateSeName("", obj.Name, true);
             UrlBLL.Update(url);
             CateBLL.Update(model);
             CacheManager.Remove(Consts.CategoryCacheKey);
             CacheManager.Remove(Consts.UrlRecordCacheKey);
             return(Json(true, JsonRequestBehavior.AllowGet));
         }
     }
 }
Пример #2
0
 public ActionResult Delete(Guid id)
 {
     foreach (Guid gid in GetIdAndChildId(TableCache.Where(o => o.Id == id).ToList()))
     {
         Category  obj       = CateBLL.GetById(gid);
         UrlRecord urlRecord = UrlBLL.Table.FirstOrDefault(o => o.EntityName == "Category" && o.EntityId == obj.Id);
         if (urlRecord != null)
         {
             UrlBLL.Delete(urlRecord);
         }
         CateBLL.Delete(obj);
     }
     CacheManager.Remove(Consts.CategoryCacheKey);
     CacheManager.Remove(Consts.UrlRecordCacheKey);
     return(Json(true, JsonRequestBehavior.AllowGet));
 }