Exemple #1
0
        /// <summary>
        /// 生成帮助中心左侧菜单
        /// </summary>
        /// <param name="helper">HtmlHelper</param>
        /// <param name="viewContext">当前视图上下文</param>
        /// <returns></returns>
        public static IHtmlString CreateHelpMenu(this HtmlHelper helper, ViewContext viewContext)
        {
            var data          = viewContext.RouteData;
            var id            = data.Values["id"] ?? "0";
            var mainCatalogId = Convert.ToInt32(id);
            var cat           = CatalogCacheManager.FindById(mainCatalogId);
            var isRoot        = cat.ParentID == 0;

            if (!isRoot)
            {
                mainCatalogId = CatalogCacheManager.FindById(cat.ParentID).ID;
            }
            var parents = CatalogCacheManager.FindAllEnabledRoots();
            var sb      = new StringBuilder();

            sb.AppendFormat("<ul class='list-unstyled'>");
            parents.ForEach(x =>
            {
                sb.AppendFormat("<li>");
                sb.AppendFormat("<a{0} href='/help/catalog/{1}'>{2}</a>", x.ID == mainCatalogId ? " class='active'" : "", x.ID, x.ClassName);
                sb.AppendFormat("</li>");
            });
            sb.AppendFormat("</ul>");
            return(MvcHtmlString.Create(sb.ToString()));
        }
Exemple #2
0
        public ActionResult Index()
        {
            var model = CatalogCacheManager.FindAllEnabledRoots().Select(x => new CatalogForIndexViewModel
            {
                ArticleCount = x.Count,
                Description  = x.Description,
                Icon         = x.Icon,
                Id           = x.ID,
                Name         = x.ClassName,
                ParentId     = x.ParentID,
                Sort         = x.Sort
            }).ToList();

            return(View(model));
        }