/// <summary> /// 树形节点数据 /// </summary> /// <returns></returns> public ActionResult Tree(bool showIcon = false) { List <TreeNode> _nodes = new List <TreeNode>(); //栏目并进行排序使最深的节点排在最前 var _categories = categoryManager.FindList(0, null, new OrderParam[] { new OrderParam() { Method = OrderMethod.ASC, PropertyName = "ParentPath" }, new OrderParam() { Method = OrderMethod.ASC, PropertyName = "Order" } }); TreeNode _node; //遍历常规栏目 foreach (var _category in _categories) { _node = new TreeNode() { pId = _category.ParentID, id = _category.ID, name = _category.Name, url = Url.Action("Modify", "Category", new { id = _category.ID }) }; if (showIcon) { switch (_category.Type) { case CategoryType.General: _node.icon = Url.Content("~/Content/Images/folder.png"); break; case CategoryType.Page: _node.icon = Url.Content("~/Content/Images/page.png"); break; case CategoryType.Link: _node.icon = Url.Content("~/Content/Images/link.png"); break; } } _nodes.Add(_node); } return(Json(_nodes)); }
// [Import] //private ILeaveMsgManager leaveMsgManager; /// <summary> /// 侧栏内容 /// </summary> /// <returns></returns> public ActionResult _HomeSideNavPartial() { //获取一些侧栏信息 List <Category> categories = categoryManager.FindList().OrderBy(c => c.Depth).ToList(); List <Blog> blogs = blogManager.FindList().OrderByDescending(b => b.CreateTime).Take(8).ToList(); List <Blog> blogs2 = blogManager.FindList().OrderByDescending(b => b.Volume).Take(8).ToList(); ViewBag.NewBlog = blogs; ViewBag.ReadBlog = blogs2; return(PartialView(categories)); }