public override IHtmlContent Render(IHtmlHelper html) { FillMissingAttributes(); var expandableItem = new TagBuilder("li"); expandableItem.AddCssClass("expandable"); expandableItem.Attributes["id"] = $"{Caption.ToLower()}-models"; var link = html.ActionLink(Caption.ToUpper(), Action, Controller, new { brandID = RouteValues }); expandableItem.InnerHtml.AppendHtml(link); if (InnerContent is null) { return(expandableItem); } var subPanel = new TagBuilder("div"); subPanel.AddCssClass("sub-panel"); if (InnerContent.Count == 1) { InnerContent.First().FillMissingAttributes(); foreach (var model in InnerContent.First().InnerContent) { subPanel.InnerHtml.AppendHtml(model.Render(html)); } } else { foreach (var group in InnerContent) { subPanel.InnerHtml.AppendHtml(group.Render(html)); } } expandableItem.InnerHtml.AppendHtml(subPanel); return(expandableItem); }
public override IHtmlContent Render(IHtmlHelper html) { FillMissingAttributes(); var expandableItem = new TagBuilder("li"); if (InnerContent?.Any() ?? false) { expandableItem.AddCssClass("expandable"); } expandableItem.AddCssClass("slider-menu-item"); expandableItem.Attributes["id"] = $"{Caption.ToLower()}-models"; var link = html.ActionLink(Caption.ToUpper(), Action, Controller, new { brandID = RouteValues }); expandableItem.InnerHtml.AppendHtml(link); if (InnerContent is null) { return(expandableItem); } var subPanel = new TagBuilder("div"); subPanel.AddCssClass("sub-menu"); var submodelsMenu = new TagBuilder("ul"); submodelsMenu.AddCssClass("slider-menu-nav"); if (InnerContent.Count == 1) { InnerContent.First().FillMissingAttributes(); foreach (var model in InnerContent.First().InnerContent) { submodelsMenu.InnerHtml.AppendHtml(model.Render(html)); } } else { var innerContent = new List <MobileBrandSubgroupContent>(); for (var i = InnerContent.Count - 1; i >= 0; i--) { if (string.IsNullOrEmpty(InnerContent[i].Caption.Trim())) { InnerContent[i - 1].InnerContent.AddRange(InnerContent[i].InnerContent); continue; } innerContent.Add(InnerContent[i]); } innerContent.Reverse(); foreach (var group in innerContent) { submodelsMenu.InnerHtml.AppendHtml(group.Render(html)); } } subPanel.InnerHtml.AppendHtml(RenderSubmenuHeader(html)); subPanel.InnerHtml.AppendHtml(submodelsMenu); expandableItem.InnerHtml.AppendHtml(subPanel); return(expandableItem); }