public async Task <IViewComponentResult> InvokeAsync(vm.AdminSettingsMenu info) { info = info ?? new vm.AdminSettingsMenu(); info.ActiveItem = GetActiveItem(info); return(View(info)); }
public string GetActiveItem(vm.AdminSettingsMenu info) { var items = new[] { new MenuItem("GeneralSettings", Url.Index("AdminSettingsGeneral")), new MenuItem("Administrators", Url.Index("AdminSettingsAdministrators")), new MenuItem("ContentBlocks", Url.Index("AdminSettingsContentBlocks")) }; return(items.Where(i => i.MatchesCurrentUrl()).WithMax(x => x.Url.Split('?').First().Length)?.Key); }