Example #1
0
 /// <summary>
 /// 添加导航
 /// </summary>
 /// <param name="nav"></param>
 public void AddNav(ENav nav)
 {
     _rep.Add(nav);
     _cacheService.RemoveByKey(CacheKey.Cms_Navs_All);
 }
Example #2
0
 /// <summary>
 /// 递归获取导航集合结构
 /// </summary>
 /// <param name="root"></param>
 private void GetSubNavListByRecursion(ENav root, List<ENav> list)
 {
     //获取下一级菜单
     var children = GetAllNavsFromCache().Where(p => p.NavParentId == root.Id).OrderByDescending(p => p.NavOrderId).ToList();
     if (children.Count > 0)
     {
         list.AddRange(children);
         foreach (var sub in children)
         {
             GetSubNavListByRecursion(sub, list);
         }
     }
 }
Example #3
0
 /// <summary>
 /// 递归获取导航集合结构
 /// </summary>
 /// <param name="root"></param>
 /// <param name="allNavList"></param>
 private void GetSubNavListByRecursion(ENav root, List<ENav> list, List<ENav> allNavList)
 {
     //获取下一级菜单
     var children = allNavList.Where(p => p.NavParentId == root.Id).ToList();
     if (children.Count > 0)
     {
         list.AddRange(children);
         foreach (var sub in children)
         {
             GetSubNavListByRecursion(sub, list, allNavList);
         }
     }
 }
Example #4
0
 /// <summary>
 /// 递归获取导航树结构
 /// </summary>
 /// <param name="root"></param>
 /// <param name="allNavList"></param>
 private void GetNavTreeByRecursion(ENav root, IList<ENav> allNavList)
 {
     //获取下一级菜单
     var children = allNavList.Where(p => p.NavParentId == root.Id).OrderBy(p => p.NavOrderId).ToList();
     if (children.Count > 0)
     {
         root.Children = children;
         foreach (var sub in root.Children)
         {
             GetNavTreeByRecursion(sub, allNavList);
         }
     }
 }
Example #5
0
 /// <summary>
 /// 递归获取导航树结构
 /// </summary>
 /// <param name="root"></param>
 /// <param name="allNavCategorys"></param>
 private void GetNavTreeByRecursion(ENav root)
 {
     //获取下一级菜单
     var children = GetAllNavsFromCache().Where(p => p.NavParentId == root.Id).OrderByDescending(p => p.NavOrderId).ToList();
     if (children.Count > 0)
     {
         root.Children = children;
         foreach (var sub in root.Children)
         {
             GetNavTreeByRecursion(sub);
         }
     }
 }
Example #6
0
 /// <summary>
 /// 保存导航
 /// </summary>
 /// <param name="nav"></param>
 public void SaveNav(ENav nav)
 {
     _rep.Save(nav, p => p.Id == nav.Id);
     _cacheService.RemoveByKey(CacheKey.Cms_Navs_All);
 }
Example #7
0
 /// <summary>
 /// 递归获取导航集合结构
 /// </summary>
 /// <param name="navId"></param>
 public IList<ENav> GetSubNavs(int? navId)
 {
     List<ENav> list = new List<ENav>();
     if (navId.HasValue)
     {
         ENav root = GetNavByIdFromCache(navId.Value);
         GetSubNavListByRecursion(root, list);
         return list;
     }
     else
     {
         ENav root = new ENav() { Id = navId ?? 0, NavName = "导航" };
         IList<ENav> allNavList = _rep.GetAll<ENav>(p => p.NavOrderId.Desc());
         GetSubNavListByRecursion(root, allNavList.ToList());
         return list;
     }
 }
Example #8
0
 /// <summary>
 /// 获取导航树结构
 /// </summary>
 /// <returns></returns>
 public ENav GetNavTreeById(int? navId)
 {
     if (navId.HasValue)
     {
         ENav root = GetNavByIdFromCache(navId.Value);
         GetNavTreeByRecursion(root);
         return root;
     }
     else
     {
         ENav root = new ENav() { Id = navId ?? 0, NavName = "导航" };
         IList<ENav> allNavList = GetAllNavsFromCache();
         GetNavTreeByRecursion(root, allNavList);
         return root;
     }
 }