Example #1
0
        public ActionResult CategoryTreeJson()
        {
            List <EasyUITree> list = GetTreeJson(TableCache.Where(o => o.ParentId == null).ToList());

            list.Insert(0, new EasyUITree {
            });
            return(Json(list, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public List <Guid> GetIdAndChildId(List <Category> query)
        {
            List <Guid> list = new List <Guid>();

            foreach (Category item in query)
            {
                list.Add(item.Id);
                if (TableCache.Any(o => o.ParentId == item.Id))
                {
                    list.AddRange(GetIdAndChildId(TableCache.Where(o => o.ParentId == item.Id).ToList()));
                }
            }
            return(list);
        }
Example #3
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));
 }
Example #4
0
        private List <EasyUITree> GetTreeJson(List <Category> query)
        {
            List <EasyUITree> list = new List <EasyUITree>();

            foreach (Category item in query)
            {
                EasyUITree obj = new EasyUITree();
                obj.id   = item.Id;
                obj.text = item.Name;
                if (TableCache.Any(o => o.ParentId == item.Id))
                {
                    obj.children = GetTreeJson(TableCache.Where(o => o.ParentId == item.Id).ToList());
                }
                list.Add(obj);
            }
            return(list);
        }