private NavigationNode EnsureRootQuickLaunchNavigationNode( WebModelHost webModelHost, QuickLaunchNavigationNodeDefinition quickLaunchModel) { NavigationNodeCollection quickLaunch = null; var context = webModelHost.HostWeb.Context; var existingNode = GetRootNavigationNode(webModelHost, quickLaunchModel, out quickLaunch); var previousNode = quickLaunch.Count > 0 ? quickLaunch.Last() : null; InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = existingNode, ObjectType = typeof(NavigationNode), ObjectDefinition = quickLaunchModel, ModelHost = webModelHost }); if (existingNode == null) { existingNode = quickLaunch.Add(new NavigationNodeCreationInformation { Title = quickLaunchModel.Title, IsExternal = quickLaunchModel.IsExternal, Url = quickLaunchModel.Url, PreviousNode = previousNode }); context.ExecuteQuery(); } existingNode.Title = quickLaunchModel.Title; existingNode.Url = quickLaunchModel.Url; existingNode.IsVisible = quickLaunchModel.IsVisible; InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = existingNode, ObjectType = typeof(NavigationNode), ObjectDefinition = quickLaunchModel, ModelHost = webModelHost }); existingNode.Update(); context.ExecuteQuery(); return(existingNode); }
private NavigationNode EnsureRootNavigationNode( WebModelHost webModelHost, NavigationNodeDefinitionBase navigationNodeModel) { NavigationNodeCollection quickLaunch = null; var context = webModelHost.HostWeb.Context; var existingNode = GetRootNavigationNode(webModelHost, navigationNodeModel, out quickLaunch); var previousNode = quickLaunch.Count > 0 ? quickLaunch.Last() : null; InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = existingNode, ObjectType = typeof(NavigationNode), ObjectDefinition = navigationNodeModel, ModelHost = webModelHost }); if (existingNode == null) { TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new navigation node"); existingNode = quickLaunch.Add(new NavigationNodeCreationInformation { Title = navigationNodeModel.Title, IsExternal = navigationNodeModel.IsExternal, Url = navigationNodeModel.Url, PreviousNode = previousNode }); context.ExecuteQueryWithTrace(); } else { TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing navigation node"); } existingNode.Title = navigationNodeModel.Title; existingNode.Url = navigationNodeModel.Url; existingNode.IsVisible = navigationNodeModel.IsVisible; InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = existingNode, ObjectType = typeof(NavigationNode), ObjectDefinition = navigationNodeModel, ModelHost = webModelHost }); existingNode.Update(); context.ExecuteQueryWithTrace(); return(existingNode); }