Exemple #1
0
 /// <summary>
 /// 递归获取展示分类集合结构
 /// </summary>
 /// <param name="root"></param>
 /// <param name="allNavList"></param>
 private void GetSubShowItemCategoryListByRecursion(EShowItemCategory root, List<EShowItemCategory> list, List<EShowItemCategory> allNavList)
 {
     //获取下一级菜单
     var children = allNavList.Where(p => p.ShowItemCategoryParentId == root.Id).ToList();
     if (children.Count > 0)
     {
         list.AddRange(children);
         foreach (var sub in children)
         {
             GetSubShowItemCategoryListByRecursion(sub, list, allNavList);
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// 递归获取菜单树结构
 /// </summary>
 /// <param name="root"></param>
 /// <param name="allShowItemCategorys"></param>
 private void GetShowItemCategoryTreeByRecursion(EShowItemCategory root, IList<EShowItemCategory> allShowItemCategorys)
 {
     //获取下一级菜单
     var children = allShowItemCategorys.Where(p => p.ShowItemCategoryParentId == root.Id).ToList();
     if (children.Count > 0)
     {
         root.Children = children;
         foreach (var sub in root.Children)
         {
             GetShowItemCategoryTreeByRecursion(sub, allShowItemCategorys);
         }
     }
 }
Exemple #3
0
 public void SaveShowItemCategory(EShowItemCategory showItemCategory)
 {
     _rep.Save(showItemCategory, p => p.Id == showItemCategory.Id);
 }
Exemple #4
0
 /// <summary>
 /// 递归获取展示分类集合结构
 /// </summary>
 /// <param name="showItemCategoryId"></param>
 public IList<EShowItemCategory> GetSubShowItemCategoryList(int? showItemCategoryId)
 {
     List<EShowItemCategory> list = new List<EShowItemCategory>();
     if (showItemCategoryId.HasValue)
     {
         EShowItemCategory root = _rep.Get<EShowItemCategory>(p => p.Id == showItemCategoryId);
         GetSubShowItemCategoryListByRecursion(root, list);
         return list;
     }
     else
     {
         EShowItemCategory root = new EShowItemCategory() { Id = showItemCategoryId ?? 0, ShowItemCategoryName = "展示分类" };
         IList<EShowItemCategory> allNavList = _rep.GetAll<EShowItemCategory>(p => p.Id.Desc());
         GetSubShowItemCategoryListByRecursion(root, allNavList.ToList());
         return list;
     }
 }
Exemple #5
0
 /// <summary>
 /// 获取展示分类树结构
 /// </summary>
 /// <returns></returns>
 public EShowItemCategory GetShowItemCategoryTree(int? showItemCategoryId)
 {
     EShowItemCategory root = null;
     if (showItemCategoryId.HasValue)
     {
         root = _rep.Get<EShowItemCategory>(p => p.Id == showItemCategoryId);
         root.ShowItemCategoryName = "根分类";
     }
     else 
     {
         root = new EShowItemCategory() { Id = 0, ShowItemCategoryName = "站点" };
     }
    
     IList<EShowItemCategory> allShowItemCategorys = _rep.GetAll<EShowItemCategory>(p => p.ShowItemCategoryOrderId.Asc());
     GetShowItemCategoryTreeByRecursion(root, allShowItemCategorys);
     return root;
 }
Exemple #6
0
 public void AddShowItemCategory(EShowItemCategory showItemCategory)
 {
     using (var dmTrans = _rep.GetTransaction())
     {
         try
         {
             var tran = dmTrans.BeginTransaction();
             _rep.Add(showItemCategory, tran);
             dmTrans.Commit();
         }
         catch
         {
             dmTrans.Rollback();
             throw;
         }
     }
 }