Class ContentService
Represents the Content Service, which is an easy access to operations involving IContent
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public class ContentService : ScopeRepositoryService, IContentService, IContentServiceBase, IService, IContentServiceOperations
Constructors
ContentService(IDatabaseUnitOfWorkProvider, RepositoryFactory, ILogger, IEventMessagesFactory, IDataTypeService, IUserService)
Declaration
public ContentService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, ILogger logger, IEventMessagesFactory eventMessagesFactory, IDataTypeService dataTypeService, IUserService userService)
Parameters
Type | Name | Description |
---|---|---|
IDatabaseUnitOfWorkProvider | provider | |
RepositoryFactory | repositoryFactory | |
ILogger | logger | |
IEventMessagesFactory | eventMessagesFactory | |
IDataTypeService | dataTypeService | |
IUserService | userService |
Methods
AssignContentPermission(IContent, Char, IEnumerable<Int32>)
Assigns a single permission to the current content item for the specified group ids
Declaration
public void AssignContentPermission(IContent entity, char permission, IEnumerable<int> groupIds)
Parameters
Type | Name | Description |
---|---|---|
IContent | entity | |
System.Char | permission | |
System.Collections.Generic.IEnumerable<System.Int32> | groupIds |
BuildXmlCache()
This builds the Xml document used for the XML cache
Declaration
public XmlDocument BuildXmlCache()
Returns
Type | Description |
---|---|
System.Xml.XmlDocument |
Copy(IContent, Int32, Boolean, Boolean, Int32)
Copies an IContent object by creating a new Content object of the same type and copies all data from the current to the new copy which is returned.
Declaration
public IContent Copy(IContent content, int parentId, bool relateToOriginal, bool recursive, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to copy |
System.Int32 | parentId | Id of the Content's new Parent |
System.Boolean | relateToOriginal | Boolean indicating whether the copy should be related to the original |
System.Boolean | recursive | A value indicating whether to recursively copy children. |
System.Int32 | userId | Optional Id of the User copying the Content |
Returns
Type | Description |
---|---|
IContent | The newly created IContent object |
Copy(IContent, Int32, Boolean, Int32)
Copies an IContent object by creating a new Content object of the same type and copies all data from the current to the new copy which is returned. Recursively copies all children.
Declaration
public IContent Copy(IContent content, int parentId, bool relateToOriginal, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to copy |
System.Int32 | parentId | Id of the Content's new Parent |
System.Boolean | relateToOriginal | Boolean indicating whether the copy should be related to the original |
System.Int32 | userId | Optional Id of the User copying the Content |
Returns
Type | Description |
---|---|
IContent | The newly created IContent object |
Count(String)
Declaration
public int Count(string contentTypeAlias = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | contentTypeAlias |
Returns
Type | Description |
---|---|
System.Int32 |
CountChildren(Int32, String)
Declaration
public int CountChildren(int parentId, string contentTypeAlias = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | parentId | |
System.String | contentTypeAlias |
Returns
Type | Description |
---|---|
System.Int32 |
CountDescendants(Int32, String)
Declaration
public int CountDescendants(int parentId, string contentTypeAlias = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | parentId | |
System.String | contentTypeAlias |
Returns
Type | Description |
---|---|
System.Int32 |
CountPublished(String)
Declaration
public int CountPublished(string contentTypeAlias = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | contentTypeAlias |
Returns
Type | Description |
---|---|
System.Int32 |
CreateContent(String, Guid, String, Int32)
Creates an IContent object using the alias of the IContentType that this Content should based on.
Declaration
public IContent CreateContent(string name, Guid parentId, string contentTypeAlias, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the Content object |
System.Guid | parentId | Id of Parent for the new Content |
System.String | contentTypeAlias | Alias of the IContentType |
System.Int32 | userId | Optional id of the user creating the content |
Returns
Type | Description |
---|---|
IContent | IContent |
Remarks
Note that using this method will simply return a new IContent without any identity as it has not yet been persisted. It is intended as a shortcut to creating new content objects that does not invoke a save operation against the database.
CreateContent(String, Int32, String, Int32)
Creates an IContent object using the alias of the IContentType that this Content should based on.
Declaration
public IContent CreateContent(string name, int parentId, string contentTypeAlias, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the Content object |
System.Int32 | parentId | Id of Parent for the new Content |
System.String | contentTypeAlias | Alias of the IContentType |
System.Int32 | userId | Optional id of the user creating the content |
Returns
Type | Description |
---|---|
IContent | IContent |
Remarks
Note that using this method will simply return a new IContent without any identity as it has not yet been persisted. It is intended as a shortcut to creating new content objects that does not invoke a save operation against the database.
CreateContent(String, IContent, String, Int32)
Creates an IContent object using the alias of the IContentType that this Content should based on.
Declaration
public IContent CreateContent(string name, IContent parent, string contentTypeAlias, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the Content object |
IContent | parent | Parent IContent object for the new Content |
System.String | contentTypeAlias | Alias of the IContentType |
System.Int32 | userId | Optional id of the user creating the content |
Returns
Type | Description |
---|---|
IContent | IContent |
Remarks
Note that using this method will simply return a new IContent without any identity as it has not yet been persisted. It is intended as a shortcut to creating new content objects that does not invoke a save operation against the database.
CreateContentFromBlueprint(IContent, String, Int32)
Declaration
public IContent CreateContentFromBlueprint(IContent blueprint, string name, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | blueprint | |
System.String | name | |
System.Int32 | userId |
Returns
Type | Description |
---|---|
IContent |
CreateContentWithIdentity(String, Int32, String, Int32)
Creates and saves an IContent object using the alias of the IContentType that this Content should based on.
Declaration
public IContent CreateContentWithIdentity(string name, int parentId, string contentTypeAlias, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the Content object |
System.Int32 | parentId | Id of Parent for the new Content |
System.String | contentTypeAlias | Alias of the IContentType |
System.Int32 | userId | Optional id of the user creating the content |
Returns
Type | Description |
---|---|
IContent | IContent |
Remarks
This method returns an IContent object that has been persisted to the database and therefor has an identity.
CreateContentWithIdentity(String, IContent, String, Int32)
Creates and saves an IContent object using the alias of the IContentType that this Content should based on.
Declaration
public IContent CreateContentWithIdentity(string name, IContent parent, string contentTypeAlias, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the Content object |
IContent | parent | Parent IContent object for the new Content |
System.String | contentTypeAlias | Alias of the IContentType |
System.Int32 | userId | Optional id of the user creating the content |
Returns
Type | Description |
---|---|
IContent | IContent |
Remarks
This method returns an IContent object that has been persisted to the database and therefor has an identity.
Delete(IContent, Int32)
Permanently deletes an IContent object as well as all of its Children.
Declaration
public void Delete(IContent content, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to delete |
System.Int32 | userId | Optional Id of the User deleting the Content |
Remarks
This method will also delete associated media files, child content and possibly associated domains.
DeleteBlueprint(IContent, Int32)
Declaration
public void DeleteBlueprint(IContent content, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | |
System.Int32 | userId |
DeleteBlueprintsOfType(Int32, Int32)
Declaration
public void DeleteBlueprintsOfType(int contentTypeId, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | contentTypeId | |
System.Int32 | userId |
DeleteBlueprintsOfTypes(IEnumerable<Int32>, Int32)
Declaration
public void DeleteBlueprintsOfTypes(IEnumerable<int> contentTypeIds, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Int32> | contentTypeIds | |
System.Int32 | userId |
DeleteContentOfType(Int32, Int32)
Deletes all content of specified type. All children of deleted content is moved to Recycle Bin.
Declaration
public void DeleteContentOfType(int contentTypeId, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | contentTypeId | Id of the IContentType |
System.Int32 | userId | Optional Id of the user issueing the delete operation |
Remarks
This needs extra care and attention as its potentially a dangerous and extensive operation
DeleteContentOfTypes(IEnumerable<Int32>, Int32)
Deletes all content of the specified types. All Descendants of deleted content that is not of these types is moved to Recycle Bin.
Declaration
public void DeleteContentOfTypes(IEnumerable<int> contentTypeIds, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Int32> | contentTypeIds | Id of the IContentType |
System.Int32 | userId | Optional Id of the user issueing the delete operation |
DeleteVersion(Int32, Guid, Boolean, Int32)
Permanently deletes specific version(s) from an IContent object. This method will never delete the latest version of a content item.
Declaration
public void DeleteVersion(int id, Guid versionId, bool deletePriorVersions, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IContent object to delete a version from |
System.Guid | versionId | Id of the version to delete |
System.Boolean | deletePriorVersions | Boolean indicating whether to delete versions prior to the versionId |
System.Int32 | userId | Optional Id of the User deleting versions of a Content object |
DeleteVersions(Int32, DateTime, Int32)
Permanently deletes versions from an IContent object prior to a specific date. This method will never delete the latest version of a content item.
Declaration
public void DeleteVersions(int id, DateTime versionDate, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IContent object to delete versions from |
System.DateTime | versionDate | Latest version date |
System.Int32 | userId | Optional Id of the User deleting versions of a Content object |
EmptyRecycleBin()
Empties the Recycle Bin by deleting all IContent that resides in the bin
Declaration
public void EmptyRecycleBin()
GetAncestors(Int32)
Gets a collection of IContent objects, which are ancestors of the current content.
Declaration
public IEnumerable<IContent> GetAncestors(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IContent to retrieve ancestors for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetAncestors(IContent)
Gets a collection of IContent objects, which are ancestors of the current content.
Declaration
public IEnumerable<IContent> GetAncestors(IContent content)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | IContent to retrieve ancestors for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetBlueprintById(Guid)
Declaration
public IContent GetBlueprintById(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id |
Returns
Type | Description |
---|---|
IContent |
GetBlueprintById(Int32)
Declaration
public IContent GetBlueprintById(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id |
Returns
Type | Description |
---|---|
IContent |
GetBlueprintsForContentTypes(Int32[])
Declaration
public IEnumerable<IContent> GetBlueprintsForContentTypes(params int[] documentTypeIds)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | documentTypeIds |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> |
GetById(Guid)
Gets an IContent object by its 'UniqueId'
Declaration
public IContent GetById(Guid key)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | key | Guid key of the Content to retrieve |
Returns
Type | Description |
---|---|
IContent | IContent |
GetById(Int32)
Gets an IContent object by Id
Declaration
public IContent GetById(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Content to retrieve |
Returns
Type | Description |
---|---|
IContent | IContent |
GetByIds(IEnumerable<Guid>)
Gets IContent objects by Ids
Declaration
public IEnumerable<IContent> GetByIds(IEnumerable<Guid> ids)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Guid> | ids | Ids of the Content to retrieve |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | IContent |
GetByIds(IEnumerable<Int32>)
Gets IContent objects by Ids
Declaration
public IEnumerable<IContent> GetByIds(IEnumerable<int> ids)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Int32> | ids | Ids of the Content to retrieve |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | IContent |
GetByLevel(Int32)
Gets a collection of IContent objects by Level
Declaration
public IEnumerable<IContent> GetByLevel(int level)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | level | The level to retrieve Content from |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetByVersion(Guid)
Gets a specific version of an IContent item.
Declaration
public IContent GetByVersion(Guid versionId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | versionId | Id of the version to retrieve |
Returns
Type | Description |
---|---|
IContent | An IContent item |
GetChildren(Int32)
Gets a collection of IContent objects by Parent Id
Declaration
public IEnumerable<IContent> GetChildren(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Children from |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetChildrenByName(Int32, String)
Gets a collection of IContent objects by its name or partial name
Declaration
public IEnumerable<IContent> GetChildrenByName(int parentId, string name)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | parentId | Id of the Parent to retrieve Children from |
System.String | name | Full or partial name of the children |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetContentForExpiration()
Gets a collection of IContent objects, which has an expiration date less than or equal to today.
Declaration
public IEnumerable<IContent> GetContentForExpiration()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetContentForRelease()
Gets a collection of IContent objects, which has a release date less than or equal to today.
Declaration
public IEnumerable<IContent> GetContentForRelease()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetContentInRecycleBin()
Gets a collection of an IContent objects, which resides in the Recycle Bin
Declaration
public IEnumerable<IContent> GetContentInRecycleBin()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetContentOfContentType(Int32)
Gets a collection of IContent objects by the Id of the IContentType
Declaration
public IEnumerable<IContent> GetContentOfContentType(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IContentType |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetDescendants(Int32)
Gets a collection of IContent objects by Parent Id
Declaration
public IEnumerable<IContent> GetDescendants(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Descendants from |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetDescendants(IContent)
Gets a collection of IContent objects by Parent Id
Declaration
public IEnumerable<IContent> GetDescendants(IContent content)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | IContent item to retrieve Descendants from |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetPagedChildren(Int32, Int32, Int32, out Int32, String, Direction, String)
Declaration
[Obsolete("Use the overload with 'long' parameter types instead")]
public IEnumerable<IContent> GetPagedChildren(int id, int pageIndex, int pageSize, out int totalChildren, string orderBy, Direction orderDirection, string filter = "")
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | |
System.Int32 | pageIndex | |
System.Int32 | pageSize | |
System.Int32 | totalChildren | |
System.String | orderBy | |
Direction | orderDirection | |
System.String | filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> |
GetPagedChildren(Int32, Int64, Int32, out Int64, String, Direction, Boolean, String)
Gets a collection of IContent objects by Parent Id
Declaration
public IEnumerable<IContent> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy, Direction orderDirection, bool orderBySystemField, string filter)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Children from |
System.Int64 | pageIndex | Page index (zero based) |
System.Int32 | pageSize | Page size |
System.Int64 | totalChildren | Total records query would return without paging |
System.String | orderBy | Field to order by |
Direction | orderDirection | Direction to order by |
System.Boolean | orderBySystemField | Flag to indicate when ordering by system field |
System.String | filter | Search text filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetPagedChildren(Int32, Int64, Int32, out Int64, String, Direction, String)
Gets a collection of IContent objects by Parent Id
Declaration
public IEnumerable<IContent> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy, Direction orderDirection, string filter = "")
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Children from |
System.Int64 | pageIndex | Page index (zero based) |
System.Int32 | pageSize | Page size |
System.Int64 | totalChildren | Total records query would return without paging |
System.String | orderBy | Field to order by |
Direction | orderDirection | Direction to order by |
System.String | filter | Search text filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetPagedDescendants(Int32, Int32, Int32, out Int32, String, Direction, String)
Declaration
[Obsolete("Use the overload with 'long' parameter types instead")]
public IEnumerable<IContent> GetPagedDescendants(int id, int pageIndex, int pageSize, out int totalChildren, string orderBy = "path", Direction orderDirection = Direction.Ascending, string filter = "")
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | |
System.Int32 | pageIndex | |
System.Int32 | pageSize | |
System.Int32 | totalChildren | |
System.String | orderBy | |
Direction | orderDirection | |
System.String | filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> |
GetPagedDescendants(Int32, Int64, Int32, out Int64, String, Direction, Boolean, String)
Gets a collection of IContent objects by Parent Id
Declaration
public IEnumerable<IContent> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy, Direction orderDirection, bool orderBySystemField, string filter)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Descendants from |
System.Int64 | pageIndex | Page number |
System.Int32 | pageSize | Page size |
System.Int64 | totalChildren | Total records query would return without paging |
System.String | orderBy | Field to order by |
Direction | orderDirection | Direction to order by |
System.Boolean | orderBySystemField | Flag to indicate when ordering by system field |
System.String | filter | Search text filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetPagedDescendants(Int32, Int64, Int32, out Int64, String, Direction, Boolean, IQuery<IContent>)
Gets a collection of IContent objects by Parent Id
Declaration
public IEnumerable<IContent> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy, Direction orderDirection, bool orderBySystemField, IQuery<IContent> filter)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Descendants from |
System.Int64 | pageIndex | Page number |
System.Int32 | pageSize | Page size |
System.Int64 | totalChildren | Total records query would return without paging |
System.String | orderBy | Field to order by |
Direction | orderDirection | Direction to order by |
System.Boolean | orderBySystemField | Flag to indicate when ordering by system field |
IQuery<IContent> | filter | Search filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetPagedDescendants(Int32, Int64, Int32, out Int64, String, Direction, String)
Gets a collection of IContent objects by Parent Id
Declaration
public IEnumerable<IContent> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, string orderBy = "path", Direction orderDirection = Direction.Ascending, string filter = "")
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Parent to retrieve Descendants from |
System.Int64 | pageIndex | Page number |
System.Int32 | pageSize | Page size |
System.Int64 | totalChildren | Total records query would return without paging |
System.String | orderBy | Field to order by |
Direction | orderDirection | Direction to order by |
System.String | filter | Search text filter |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetPagedXmlEntries(String, Int64, Int32, out Int64)
Gets paged content descendants as XML by path
Declaration
public IEnumerable<XElement> GetPagedXmlEntries(string path, long pageIndex, int pageSize, out long totalRecords)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Path starts with |
System.Int64 | pageIndex | Page number |
System.Int32 | pageSize | Page size |
System.Int64 | totalRecords | Total records the query would return without paging |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> | A paged enumerable of XML entries of content items |
GetParent(Int32)
Gets the parent of the current content as an IContent item.
Declaration
public IContent GetParent(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IContent to retrieve the parent from |
Returns
Type | Description |
---|---|
IContent | Parent IContent object |
GetParent(IContent)
Gets the parent of the current content as an IContent item.
Declaration
public IContent GetParent(IContent content)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | IContent to retrieve the parent from |
Returns
Type | Description |
---|---|
IContent | Parent IContent object |
GetPermissionsForEntity(IContent)
Returns implicit/inherited permissions assigned to the content item for all user groups
Declaration
public EntityPermissionCollection GetPermissionsForEntity(IContent content)
Parameters
Type | Name | Description |
---|---|---|
IContent | content |
Returns
Type | Description |
---|---|
EntityPermissionCollection |
GetPublishedVersion(Int32)
Gets the published version of an IContent item
Declaration
public IContent GetPublishedVersion(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IContent to retrieve version from |
Returns
Type | Description |
---|---|
IContent | An IContent item |
GetPublishedVersion(IContent)
Gets the published version of a IContent item.
Declaration
public IContent GetPublishedVersion(IContent content)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The content item. |
Returns
Type | Description |
---|---|
IContent | The published version, if any; otherwise, null. |
GetRootContent()
Gets a collection of IContent objects, which reside at the first level / root
Declaration
public IEnumerable<IContent> GetRootContent()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
GetVersionIds(Int32, Int32)
Gets a list of all version Ids for the given content item ordered so latest is first
Declaration
public IEnumerable<Guid> GetVersionIds(int id, int maxRows)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | |
System.Int32 | maxRows | The maximum number of rows to return |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Guid> |
GetVersions(Int32)
Gets a collection of an IContent objects versions by Id
Declaration
public IEnumerable<IContent> GetVersions(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IContent> | An Enumerable list of IContent objects |
HasChildren(Int32)
Checks whether an IContent item has any children
Declaration
public bool HasChildren(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IContent |
Returns
Type | Description |
---|---|
System.Boolean | True if the content has any children otherwise False |
HasPublishedVersion(Int32)
Checks whether an IContent item has any published versions
Declaration
public bool HasPublishedVersion(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IContent |
Returns
Type | Description |
---|---|
System.Boolean | True if the content has any published version otherwise False |
IsPublishable(IContent)
Checks if the passed in IContent can be published based on the anscestors publish state.
Declaration
public bool IsPublishable(IContent content)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | IContent to check if anscestors are published |
Returns
Type | Description |
---|---|
System.Boolean | True if the Content can be published, otherwise False |
Move(IContent, Int32, Int32)
Moves an IContent object to a new location by changing its parent id.
Declaration
public void Move(IContent content, int parentId, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to move |
System.Int32 | parentId | Id of the Content's new Parent |
System.Int32 | userId | Optional Id of the User moving the Content |
Remarks
If the IContent object is already published it will be published after being moved to its new location. Otherwise it'll just be saved with a new parent id.
MoveToRecycleBin(IContent, Int32)
Deletes an IContent object by moving it to the Recycle Bin
Declaration
public void MoveToRecycleBin(IContent content, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to delete |
System.Int32 | userId | Optional Id of the User deleting the Content |
Remarks
Move an item to the Recycle Bin will result in the item being unpublished
Publish(IContent, Int32)
Publishes a single IContent object
Declaration
public bool Publish(IContent content, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to publish |
System.Int32 | userId | Optional Id of the User issueing the publishing |
Returns
Type | Description |
---|---|
System.Boolean | True if publishing succeeded, otherwise False |
PublishWithChildren(IContent, Int32)
Publishes a IContent object and all its children
Declaration
[Obsolete("Use PublishWithChildrenWithStatus instead, that method will provide more detailed information on the outcome and also allows the includeUnpublished flag")]
public bool PublishWithChildren(IContent content, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to publish along with its children |
System.Int32 | userId | Optional Id of the User issueing the publishing |
Returns
Type | Description |
---|---|
System.Boolean | True if publishing succeeded, otherwise False |
PublishWithChildrenWithStatus(IContent, Int32, Boolean)
Publishes a IContent object and all its children
Declaration
public IEnumerable<Attempt<PublishStatus>> PublishWithChildrenWithStatus(IContent content, int userId = 0, bool includeUnpublished = false)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to publish along with its children |
System.Int32 | userId | Optional Id of the User issueing the publishing |
System.Boolean | includeUnpublished | set to true if you want to also publish children that are currently unpublished |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Attempt<PublishStatus>> | True if publishing succeeded, otherwise False |
PublishWithStatus(IContent, Int32)
Publishes a single IContent object
Declaration
public Attempt<PublishStatus> PublishWithStatus(IContent content, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to publish |
System.Int32 | userId | Optional Id of the User issueing the publishing |
Returns
Type | Description |
---|---|
Attempt<PublishStatus> | True if publishing succeeded, otherwise False |
RebuildXmlStructures(Int32[])
Rebuilds all xml content in the cmsContentXml table for all documents
Declaration
public void RebuildXmlStructures(params int[] contentTypeIds)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | contentTypeIds | Only rebuild the xml structures for the content type ids passed in, if none then rebuilds the structures for all content |
ReplaceContentPermissions(EntityPermissionSet)
Declaration
public void ReplaceContentPermissions(EntityPermissionSet permissionSet)
Parameters
Type | Name | Description |
---|---|---|
EntityPermissionSet | permissionSet |
RePublishAll(Int32)
This will rebuild the xml structures for content in the database.
Declaration
public bool RePublishAll(int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | This is not used for anything |
Returns
Type | Description |
---|---|
System.Boolean | True if publishing succeeded, otherwise False |
Remarks
This is used for when a document type alias or a document type property is changed, the xml will need to be regenerated.
Rollback(Int32, Guid, Int32)
Rollback an IContent object to a previous version. This will create a new version, which is a copy of all the old data.
Declaration
public IContent Rollback(int id, Guid versionId, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the IContentbeing rolled back |
System.Guid | versionId | Id of the version to rollback to |
System.Int32 | userId | Optional Id of the User issueing the rollback of the Content |
Returns
Type | Description |
---|---|
IContent | The newly created IContent object |
Remarks
The way data is stored actually only allows us to rollback on properties and not data like Name and Alias of the Content.
Save(IEnumerable<IContent>, Int32, Boolean)
Saves a collection of IContent objects.
Declaration
public void Save(IEnumerable<IContent> contents, int userId = 0, bool raiseEvents = true)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IContent> | contents | Collection of IContent to save |
System.Int32 | userId | Optional Id of the User saving the Content |
System.Boolean | raiseEvents | Optional boolean indicating whether or not to raise events. |
Remarks
If the collection of content contains new objects that references eachother by Id or ParentId, then use the overload Save method with a collection of Lazy IContent.
Save(IContent, Int32, Boolean)
Saves a single IContent object
Declaration
public void Save(IContent content, int userId = 0, bool raiseEvents = true)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to save |
System.Int32 | userId | Optional Id of the User saving the Content |
System.Boolean | raiseEvents | Optional boolean indicating whether or not to raise events. |
SaveAndPublish(IContent, Int32, Boolean)
Saves and Publishes a single IContent object
Declaration
[Obsolete("Use SaveAndPublishWithStatus instead, that method will provide more detailed information on the outcome")]
public bool SaveAndPublish(IContent content, int userId = 0, bool raiseEvents = true)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to save and publish |
System.Int32 | userId | Optional Id of the User issueing the publishing |
System.Boolean | raiseEvents | Optional boolean indicating whether or not to raise save events. |
Returns
Type | Description |
---|---|
System.Boolean | True if publishing succeeded, otherwise False |
SaveAndPublishWithStatus(IContent, Int32, Boolean)
Saves and Publishes a single IContent object
Declaration
public Attempt<PublishStatus> SaveAndPublishWithStatus(IContent content, int userId = 0, bool raiseEvents = true)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to save and publish |
System.Int32 | userId | Optional Id of the User issueing the publishing |
System.Boolean | raiseEvents | Optional boolean indicating whether or not to raise save events. |
Returns
Type | Description |
---|---|
Attempt<PublishStatus> | True if publishing succeeded, otherwise False |
SaveBlueprint(IContent, Int32)
Declaration
public void SaveBlueprint(IContent content, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | |
System.Int32 | userId |
SendToPublication(IContent, Int32)
Sends an IContent to Publication, which executes handlers and events for the 'Send to Publication' action.
Declaration
public bool SendToPublication(IContent content, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to send to publication |
System.Int32 | userId | Optional Id of the User issueing the send to publication |
Returns
Type | Description |
---|---|
System.Boolean | True if sending publication was succesfull otherwise false |
Sort(IEnumerable<IContent>, Int32, Boolean)
Sorts a collection of IContent objects by updating the SortOrder according to the ordering of items in the passed in System.Collections.Generic.IEnumerable<T>.
Declaration
public bool Sort(IEnumerable<IContent> items, int userId = 0, bool raiseEvents = true)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IContent> | items | |
System.Int32 | userId | |
System.Boolean | raiseEvents |
Returns
Type | Description |
---|---|
System.Boolean | True if sorting succeeded, otherwise False |
Remarks
Using this method will ensure that the Published-state is maintained upon sorting so the cache is updated accordingly - as needed.
Sort(Int32[], Int32, Boolean)
Sorts a collection of IContent objects by updating the SortOrder according to the ordering of node Ids passed in.
Declaration
public bool Sort(int[] ids, int userId = 0, bool raiseEvents = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | ids | |
System.Int32 | userId | |
System.Boolean | raiseEvents |
Returns
Type | Description |
---|---|
System.Boolean | True if sorting succeeded, otherwise False |
Remarks
Using this method will ensure that the Published-state is maintained upon sorting so the cache is updated accordingly - as needed.
UnPublish(IContent, Int32)
UnPublishes a single IContent object
Declaration
public bool UnPublish(IContent content, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to publish |
System.Int32 | userId | Optional Id of the User issueing the publishing |
Returns
Type | Description |
---|---|
System.Boolean | True if unpublishing succeeded, otherwise False |
Events
Copied
Occurs after Copy
Declaration
public static event TypedEventHandler<IContentService, CopyEventArgs<IContent>> Copied
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, CopyEventArgs<IContent>> |
Copying
Occurs before Copy
Declaration
public static event TypedEventHandler<IContentService, CopyEventArgs<IContent>> Copying
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, CopyEventArgs<IContent>> |
Created
Occurs after Create
Declaration
public static event TypedEventHandler<IContentService, NewEventArgs<IContent>> Created
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, NewEventArgs<IContent>> |
Remarks
Please note that the Content object has been created, but might not have been saved so it does not have an identity yet (meaning no Id has been set).
Creating
Occurs before Create
Declaration
[Obsolete("Use the Created event instead, the Creating and Created events both offer the same functionality, Creating event has been deprecated.")]
public static event TypedEventHandler<IContentService, NewEventArgs<IContent>> Creating
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, NewEventArgs<IContent>> |
Deleted
Occurs after Delete
Declaration
public static event TypedEventHandler<IContentService, DeleteEventArgs<IContent>> Deleted
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, DeleteEventArgs<IContent>> |
DeletedBlueprint
Occurs after a blueprint has been deleted.
Declaration
public static event TypedEventHandler<IContentService, DeleteEventArgs<IContent>> DeletedBlueprint
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, DeleteEventArgs<IContent>> |
DeletedVersions
Occurs after Delete Versions
Declaration
public static event TypedEventHandler<IContentService, DeleteRevisionsEventArgs> DeletedVersions
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, DeleteRevisionsEventArgs> |
Deleting
Occurs before Delete
Declaration
public static event TypedEventHandler<IContentService, DeleteEventArgs<IContent>> Deleting
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, DeleteEventArgs<IContent>> |
DeletingVersions
Occurs before Delete Versions
Declaration
public static event TypedEventHandler<IContentService, DeleteRevisionsEventArgs> DeletingVersions
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, DeleteRevisionsEventArgs> |
EmptiedRecycleBin
Occurs after the Recycle Bin has been Emptied
Declaration
public static event TypedEventHandler<IContentService, RecycleBinEventArgs> EmptiedRecycleBin
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, RecycleBinEventArgs> |
EmptyingRecycleBin
Occurs before the Recycle Bin is emptied
Declaration
public static event TypedEventHandler<IContentService, RecycleBinEventArgs> EmptyingRecycleBin
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, RecycleBinEventArgs> |
Moved
Occurs after Move
Declaration
public static event TypedEventHandler<IContentService, MoveEventArgs<IContent>> Moved
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, MoveEventArgs<IContent>> |
Moving
Occurs before Move
Declaration
public static event TypedEventHandler<IContentService, MoveEventArgs<IContent>> Moving
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, MoveEventArgs<IContent>> |
Published
Occurs after publish.
Declaration
public static event TypedEventHandler<IPublishingStrategy, PublishEventArgs<IContent>> Published
Event Type
Type | Description |
---|---|
TypedEventHandler<IPublishingStrategy, PublishEventArgs<IContent>> |
Remarks
Proxy to the real event on the PublishingStrategy
Publishing
Occurs before publish.
Declaration
public static event TypedEventHandler<IPublishingStrategy, PublishEventArgs<IContent>> Publishing
Event Type
Type | Description |
---|---|
TypedEventHandler<IPublishingStrategy, PublishEventArgs<IContent>> |
Remarks
Proxy to the real event on the PublishingStrategy
RolledBack
Occurs after Rollback
Declaration
public static event TypedEventHandler<IContentService, RollbackEventArgs<IContent>> RolledBack
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, RollbackEventArgs<IContent>> |
RollingBack
Occurs before Rollback
Declaration
public static event TypedEventHandler<IContentService, RollbackEventArgs<IContent>> RollingBack
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, RollbackEventArgs<IContent>> |
Saved
Occurs after Save
Declaration
public static event TypedEventHandler<IContentService, SaveEventArgs<IContent>> Saved
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, SaveEventArgs<IContent>> |
SavedBlueprint
Occurs after a blueprint has been saved.
Declaration
public static event TypedEventHandler<IContentService, SaveEventArgs<IContent>> SavedBlueprint
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, SaveEventArgs<IContent>> |
Saving
Occurs before Save
Declaration
public static event TypedEventHandler<IContentService, SaveEventArgs<IContent>> Saving
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, SaveEventArgs<IContent>> |
SendingToPublish
Occurs before Send to Publish
Declaration
public static event TypedEventHandler<IContentService, SendToPublishEventArgs<IContent>> SendingToPublish
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, SendToPublishEventArgs<IContent>> |
SentToPublish
Occurs after Send to Publish
Declaration
public static event TypedEventHandler<IContentService, SendToPublishEventArgs<IContent>> SentToPublish
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, SendToPublishEventArgs<IContent>> |
Trashed
Occurs after Content is moved to Recycle Bin
Declaration
public static event TypedEventHandler<IContentService, MoveEventArgs<IContent>> Trashed
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, MoveEventArgs<IContent>> |
Trashing
Occurs before Content is moved to Recycle Bin
Declaration
public static event TypedEventHandler<IContentService, MoveEventArgs<IContent>> Trashing
Event Type
Type | Description |
---|---|
TypedEventHandler<IContentService, MoveEventArgs<IContent>> |
UnPublished
Occurs after unpublish.
Declaration
public static event TypedEventHandler<IPublishingStrategy, PublishEventArgs<IContent>> UnPublished
Event Type
Type | Description |
---|---|
TypedEventHandler<IPublishingStrategy, PublishEventArgs<IContent>> |
Remarks
Proxy to the real event on the PublishingStrategy
UnPublishing
Occurs before unpublish.
Declaration
public static event TypedEventHandler<IPublishingStrategy, PublishEventArgs<IContent>> UnPublishing
Event Type
Type | Description |
---|---|
TypedEventHandler<IPublishingStrategy, PublishEventArgs<IContent>> |
Remarks
Proxy to the real event on the PublishingStrategy
Explicit Interface Implementations
IContentServiceOperations.Delete(IContent, Int32)
Permanently deletes an IContent object.
Declaration
Attempt<OperationStatus> IContentServiceOperations.Delete(IContent content, int userId)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to delete |
System.Int32 | userId | Optional Id of the User deleting the Content |
Returns
Type | Description |
---|---|
Attempt<OperationStatus> |
Remarks
This method will also delete associated media files, child content and possibly associated domains.
IContentServiceOperations.MoveToRecycleBin(IContent, Int32)
Deletes an IContent object by moving it to the Recycle Bin
Declaration
Attempt<OperationStatus> IContentServiceOperations.MoveToRecycleBin(IContent content, int userId)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to delete |
System.Int32 | userId | Optional Id of the User deleting the Content |
Returns
Type | Description |
---|---|
Attempt<OperationStatus> |
Remarks
Move an item to the Recycle Bin will result in the item being unpublished
IContentServiceOperations.Publish(IContent, Int32)
Publishes a single IContent object
Declaration
Attempt<PublishStatus> IContentServiceOperations.Publish(IContent content, int userId)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to publish |
System.Int32 | userId | Optional Id of the User issueing the publishing |
Returns
Type | Description |
---|---|
Attempt<PublishStatus> | The published status attempt |
IContentServiceOperations.PublishWithChildren(IContent, Int32, Boolean)
Publishes a IContent object and all its children
Declaration
IEnumerable<Attempt<PublishStatus>> IContentServiceOperations.PublishWithChildren(IContent content, int userId, bool includeUnpublished)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to publish along with its children |
System.Int32 | userId | Optional Id of the User issueing the publishing |
System.Boolean | includeUnpublished |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Attempt<PublishStatus>> | The list of statuses for all published items |
IContentServiceOperations.Save(IEnumerable<IContent>, Int32, Boolean)
Saves a collection of IContent objects.
Declaration
Attempt<OperationStatus> IContentServiceOperations.Save(IEnumerable<IContent> contents, int userId, bool raiseEvents)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IContent> | contents | Collection of IContent to save |
System.Int32 | userId | Optional Id of the User saving the Content |
System.Boolean | raiseEvents | Optional boolean indicating whether or not to raise events. |
Returns
Type | Description |
---|---|
Attempt<OperationStatus> |
IContentServiceOperations.Save(IContent, Int32, Boolean)
Saves a single IContent object
Declaration
Attempt<OperationStatus> IContentServiceOperations.Save(IContent content, int userId, bool raiseEvents)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to save |
System.Int32 | userId | Optional Id of the User saving the Content |
System.Boolean | raiseEvents | Optional boolean indicating whether or not to raise events. |
Returns
Type | Description |
---|---|
Attempt<OperationStatus> |
IContentServiceOperations.SaveAndPublish(IContent, Int32, Boolean)
Saves and Publishes a single IContent object
Declaration
Attempt<PublishStatus> IContentServiceOperations.SaveAndPublish(IContent content, int userId, bool raiseEvents)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to save and publish |
System.Int32 | userId | Optional Id of the User issueing the publishing |
System.Boolean | raiseEvents | Optional boolean indicating whether or not to raise save events. |
Returns
Type | Description |
---|---|
Attempt<PublishStatus> | True if publishing succeeded, otherwise False |
IContentServiceOperations.UnPublish(IContent, Int32)
UnPublishes a single IContent object
Declaration
Attempt<UnPublishStatus> IContentServiceOperations.UnPublish(IContent content, int userId)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The IContent to publish |
System.Int32 | userId | Optional Id of the User issueing the publishing |
Returns
Type | Description |
---|---|
Attempt<UnPublishStatus> | True if unpublishing succeeded, otherwise False |