public static PageHeaderModel HeaderModel(this IHtmlHelper helper) { PageHeaderModel model = helper.GetViewData <PageHeaderModel>(); if (model == null) { model = new PageHeaderModel { Title = helper.GetPageTitle(), AddButton = null, }; if (helper.GetViewParams().ListUrl != null) { string id = RazorUtils.UrlToPageId(helper.GetViewParams().ListUrl); model.ListBreadCrumb = new BreadCrumbModel { Title = helper.Page(id), Link = helper.GetViewParams().ListUrl }; } string addUrl = helper.GetViewParams().AddUrl; if (addUrl != null) { model.AddButton = helper.AddButton(addUrl); model.EmbeddedAddButton = helper.AddButton(addUrl, "buttonGra-sm"); model.IsListPage = true; } helper.SetViewData(model); } return(model); }
public static IHtmlContent PageHeader <T>(this IHtmlHelper <T> helper, string addUrl = null, IHtmlContent addButton = null, IHtmlContent addButtonEmbedded = null) { var mod = helper.HeaderModel(); if (addButton != null && addButtonEmbedded != null) { mod.AddButton = addButton; mod.EmbeddedAddButton = addButtonEmbedded; } else if (addUrl != null) { if (mod.AddButton == null) { mod.AddButton = helper.AddButton(addUrl); } if (mod.EmbeddedAddButton == null) { mod.EmbeddedAddButton = helper.AddButton(addUrl, "buttonGra-sm"); } } return(helper.GetComponent("PageHeader", mod)); }