public static CategoryTreeItemViewModel CreateNavigationTree(IRepository repository) { var root = new CategoryTreeItemViewModel { Name = StringResource.admin_PageTreeRoot, Id = Guid.Empty }; root.InitializeSubCategories(repository); return(root); }
public static dynamic CreateTreeNode(CategoryTreeItemViewModel node, bool useIcons = true) { var icon = useIcons ? (node.Id == Guid.Empty ? "glyphicon glyphicon-home" : (node.IsCategory ? "glyphicon glyphicon-folder-open" : "glyphicon glyphicon-file")) : null; var subItems = node.Items != null?node.Items.Select(i => CreateTreeNode(i)).ToArray() : null; return(new { text = node.Name, nodes = subItems != null && subItems.Any() ? subItems : null, id = node.Id.ToString(), icon = icon, key = node.Key }); }