public async Task<UserMenu> GetMenuAsync(string menuName, long? userId) { var menuDefinition = _navigationManager.Menus.GetOrDefault(menuName); if (menuDefinition == null) { throw new OwException("There is no menu with given name: " + menuName); } var userMenu = new UserMenu(menuDefinition); await FillUserMenuItems(userId, menuDefinition.Items, userMenu.Items); return userMenu; }
private static void AppendMenu(StringBuilder sb, UserMenu menu) { sb.AppendLine(" '" + menu.Name + "': {"); sb.AppendLine(" name: '" + menu.Name + "',"); if (menu.DisplayName != null) { sb.AppendLine(" displayName: '" + menu.DisplayName + "',"); } if (menu.CustomData != null) { sb.AppendLine(" customData: " + menu.CustomData.ToJsonString(true) + ","); } sb.Append(" items: "); if (menu.Items.Count <= 0) { sb.AppendLine("[]"); } else { sb.Append("["); for (int i = 0; i < menu.Items.Count; i++) { AppendMenuItem(16, sb, menu.Items[i]); if (menu.Items.Count - 1 > i) { sb.Append(" , "); } } sb.AppendLine("]"); } sb.AppendLine(" }"); }