public ContentReference Update(NodeContent nodeContent, Node node, SaveAction saveAction) { if (string.IsNullOrEmpty(node.urlSegment) == false) { nodeContent.RouteSegment = node.urlSegment; } else { nodeContent.RouteSegment = node.code.ToLowerInvariant(); } //Set the Name nodeContent.Name = node.name; nodeContent.DisplayName = node.name; // Override with language var displayName = GetPropertyValue(node, RootCatalog.DefaultLanguage, "DisplayName"); if (string.IsNullOrEmpty(displayName) == false) { nodeContent.DisplayName = displayName; } //Publish the new content and return its ContentReference. return _contentRepository.Save(nodeContent, saveAction, AccessLevel.NoAccess); }
public ContentReference CreateNew(ContentReference parentNodeLink, Node node, ContentType nodeType) { //Create a new instance of CatalogContentTypeSample that will be a child to the specified parentNode. var nodeContent = _contentRepository.GetDefault<NodeContent>(parentNodeLink, nodeType.ID); // Set required properties nodeContent.Code = node.code; return Update(nodeContent, node, SaveAction.Publish); }
private string GetPropertyValue(Node node, string language, string propertyName) { var property = node.properties.FirstOrDefault( n => n.language.Equals(language, StringComparison.InvariantCultureIgnoreCase) && n.name.Equals(propertyName, StringComparison.InvariantCultureIgnoreCase)); if (property != null && string.IsNullOrEmpty(property.value) == false) { return property.value; } return null; }