Search Results for

    Show / Hide Table of Contents
    View Source

    Class ContentService

    Implements the content service.

    Inheritance
    object
    RepositoryService
    Namespace: Umbraco.Cms.Core.Services
    Assembly: Umbraco.Core.dll
    Syntax
    public class ContentService : RepositoryService, IContentService, IContentServiceBase<IContent>, IContentServiceBase, IService

    Constructors

    View Source

    ContentService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IDocumentRepository, IEntityRepository, IAuditRepository, IContentTypeRepository, IDocumentBlueprintRepository, ILanguageRepository, Lazy<IPropertyValidationService>, IShortStringHelper, ICultureImpactFactory, IUserIdKeyResolver, PropertyEditorCollection, IIdKeyMap, IOptionsMonitor<ContentSettings>, IRelationService)

    Declaration
    [Obsolete("Use the non-obsolete constructor instead. Scheduled removal in v19.")]
    public ContentService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IDocumentRepository documentRepository, IEntityRepository entityRepository, IAuditRepository auditRepository, IContentTypeRepository contentTypeRepository, IDocumentBlueprintRepository documentBlueprintRepository, ILanguageRepository languageRepository, Lazy<IPropertyValidationService> propertyValidationService, IShortStringHelper shortStringHelper, ICultureImpactFactory cultureImpactFactory, IUserIdKeyResolver userIdKeyResolver, PropertyEditorCollection propertyEditorCollection, IIdKeyMap idKeyMap, IOptionsMonitor<ContentSettings> optionsMonitor, IRelationService relationService)
    Parameters
    Type Name Description
    ICoreScopeProvider provider
    ILoggerFactory loggerFactory
    IEventMessagesFactory eventMessagesFactory
    IDocumentRepository documentRepository
    IEntityRepository entityRepository
    IAuditRepository auditRepository
    IContentTypeRepository contentTypeRepository
    IDocumentBlueprintRepository documentBlueprintRepository
    ILanguageRepository languageRepository
    Lazy<IPropertyValidationService> propertyValidationService
    IShortStringHelper shortStringHelper
    ICultureImpactFactory cultureImpactFactory
    IUserIdKeyResolver userIdKeyResolver
    PropertyEditorCollection propertyEditorCollection
    IIdKeyMap idKeyMap
    IOptionsMonitor<ContentSettings> optionsMonitor
    IRelationService relationService
    View Source

    ContentService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IDocumentRepository, IEntityRepository, IAuditRepository, IAuditService, IContentTypeRepository, IDocumentBlueprintRepository, ILanguageRepository, Lazy<IPropertyValidationService>, IShortStringHelper, ICultureImpactFactory, IUserIdKeyResolver, PropertyEditorCollection, IIdKeyMap, IOptionsMonitor<ContentSettings>, IRelationService)

    Declaration
    [Obsolete("Use the non-obsolete constructor instead. Scheduled removal in v19.")]
    public ContentService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IDocumentRepository documentRepository, IEntityRepository entityRepository, IAuditRepository auditRepository, IAuditService auditService, IContentTypeRepository contentTypeRepository, IDocumentBlueprintRepository documentBlueprintRepository, ILanguageRepository languageRepository, Lazy<IPropertyValidationService> propertyValidationService, IShortStringHelper shortStringHelper, ICultureImpactFactory cultureImpactFactory, IUserIdKeyResolver userIdKeyResolver, PropertyEditorCollection propertyEditorCollection, IIdKeyMap idKeyMap, IOptionsMonitor<ContentSettings> optionsMonitor, IRelationService relationService)
    Parameters
    Type Name Description
    ICoreScopeProvider provider
    ILoggerFactory loggerFactory
    IEventMessagesFactory eventMessagesFactory
    IDocumentRepository documentRepository
    IEntityRepository entityRepository
    IAuditRepository auditRepository
    IAuditService auditService
    IContentTypeRepository contentTypeRepository
    IDocumentBlueprintRepository documentBlueprintRepository
    ILanguageRepository languageRepository
    Lazy<IPropertyValidationService> propertyValidationService
    IShortStringHelper shortStringHelper
    ICultureImpactFactory cultureImpactFactory
    IUserIdKeyResolver userIdKeyResolver
    PropertyEditorCollection propertyEditorCollection
    IIdKeyMap idKeyMap
    IOptionsMonitor<ContentSettings> optionsMonitor
    IRelationService relationService
    View Source

    ContentService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IDocumentRepository, IEntityRepository, IAuditService, IContentTypeRepository, IDocumentBlueprintRepository, ILanguageRepository, Lazy<IPropertyValidationService>, IShortStringHelper, ICultureImpactFactory, IUserIdKeyResolver, PropertyEditorCollection, IIdKeyMap, IOptionsMonitor<ContentSettings>, IRelationService)

    Declaration
    public ContentService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IDocumentRepository documentRepository, IEntityRepository entityRepository, IAuditService auditService, IContentTypeRepository contentTypeRepository, IDocumentBlueprintRepository documentBlueprintRepository, ILanguageRepository languageRepository, Lazy<IPropertyValidationService> propertyValidationService, IShortStringHelper shortStringHelper, ICultureImpactFactory cultureImpactFactory, IUserIdKeyResolver userIdKeyResolver, PropertyEditorCollection propertyEditorCollection, IIdKeyMap idKeyMap, IOptionsMonitor<ContentSettings> optionsMonitor, IRelationService relationService)
    Parameters
    Type Name Description
    ICoreScopeProvider provider
    ILoggerFactory loggerFactory
    IEventMessagesFactory eventMessagesFactory
    IDocumentRepository documentRepository
    IEntityRepository entityRepository
    IAuditService auditService
    IContentTypeRepository contentTypeRepository
    IDocumentBlueprintRepository documentBlueprintRepository
    ILanguageRepository languageRepository
    Lazy<IPropertyValidationService> propertyValidationService
    IShortStringHelper shortStringHelper
    ICultureImpactFactory cultureImpactFactory
    IUserIdKeyResolver userIdKeyResolver
    PropertyEditorCollection propertyEditorCollection
    IIdKeyMap idKeyMap
    IOptionsMonitor<ContentSettings> optionsMonitor
    IRelationService relationService

    Methods

    View Source

    CheckDataIntegrity(ContentDataIntegrityReportOptions)

    Checks/fixes the data integrity of node paths/levels stored in the database

    Declaration
    public ContentDataIntegrityReport CheckDataIntegrity(ContentDataIntegrityReportOptions options)
    Parameters
    Type Name Description
    ContentDataIntegrityReportOptions options
    Returns
    Type Description
    ContentDataIntegrityReport
    View Source

    Copy(IContent, int, bool, bool, int)

    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 = -1)
    Parameters
    Type Name Description
    IContent content

    The IContent to copy

    int parentId

    Id of the Content's new Parent

    bool relateToOriginal

    Boolean indicating whether the copy should be related to the original

    bool recursive

    A value indicating whether to recursively copy children.

    int userId

    Optional Id of the User copying the Content

    Returns
    Type Description
    IContent

    The newly created IContent object

    View Source

    Copy(IContent, int, bool, int)

    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 = -1)
    Parameters
    Type Name Description
    IContent content

    The IContent to copy

    int parentId

    Id of the Content's new Parent

    bool relateToOriginal

    Boolean indicating whether the copy should be related to the original

    int userId

    Optional Id of the User copying the Content

    Returns
    Type Description
    IContent

    The newly created IContent object

    View Source

    Count(string?)

    Counts documents of a given document type.

    Declaration
    public int Count(string? contentTypeAlias = null)
    Parameters
    Type Name Description
    string contentTypeAlias
    Returns
    Type Description
    int
    View Source

    CountChildren(int, string?)

    Counts child documents of a given parent, of a given document type.

    Declaration
    public int CountChildren(int parentId, string? contentTypeAlias = null)
    Parameters
    Type Name Description
    int parentId
    string contentTypeAlias
    Returns
    Type Description
    int
    View Source

    CountDescendants(int, string?)

    Counts descendant documents of a given parent, of a given document type.

    Declaration
    public int CountDescendants(int parentId, string? contentTypeAlias = null)
    Parameters
    Type Name Description
    int parentId
    string contentTypeAlias
    Returns
    Type Description
    int
    View Source

    CountPublished(string?)

    Counts published documents of a given document type.

    Declaration
    public int CountPublished(string? contentTypeAlias = null)
    Parameters
    Type Name Description
    string contentTypeAlias
    Returns
    Type Description
    int
    View Source

    Create(string, Guid, string, int)

    Creates an IContent object using the alias of the IContentType that this Content should based on.

    Declaration
    public IContent Create(string name, Guid parentId, string contentTypeAlias, int userId = -1)
    Parameters
    Type Name Description
    string name

    Name of the Content object

    Guid parentId

    Id of Parent for the new Content

    string contentTypeAlias

    Alias of the IContentType

    int 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.

    View Source

    Create(string, int, string, int)

    Creates an IContent object of a specified content type.

    Declaration
    public IContent Create(string name, int parentId, string contentTypeAlias, int userId = -1)
    Parameters
    Type Name Description
    string name

    The name of the content object.

    int parentId

    The identifier of the parent, or -1.

    string contentTypeAlias

    The alias of the content type.

    int userId

    The optional id of the user creating the content.

    Returns
    Type Description
    IContent

    The content object.

    Remarks

    This method simply returns a new, non-persisted, IContent without any identity. It is intended as a shortcut to creating new content objects that does not invoke a save operation against the database.

    View Source

    Create(string, int, IContentType, int)

    Creates an IContent object of a specified content type.

    Declaration
    public IContent Create(string name, int parentId, IContentType contentType, int userId = -1)
    Parameters
    Type Name Description
    string name

    The name of the content object.

    int parentId

    The identifier of the parent, or -1.

    IContentType contentType

    The content type of the content

    int userId

    The optional id of the user creating the content.

    Returns
    Type Description
    IContent

    The content object.

    Remarks

    This method simply returns a new, non-persisted, IContent without any identity. It is intended as a shortcut to creating new content objects that does not invoke a save operation against the database.

    View Source

    Create(string, IContent?, string, int)

    Creates an IContent object of a specified content type, under a parent.

    Declaration
    public IContent Create(string name, IContent? parent, string contentTypeAlias, int userId = -1)
    Parameters
    Type Name Description
    string name

    The name of the content object.

    IContent parent

    The parent content object.

    string contentTypeAlias

    The alias of the content type.

    int userId

    The optional id of the user creating the content.

    Returns
    Type Description
    IContent

    The content object.

    Remarks

    This method simply returns a new, non-persisted, IContent without any identity. It is intended as a shortcut to creating new content objects that does not invoke a save operation against the database.

    View Source

    CreateAndSave(string, int, string, int)

    Creates an IContent object of a specified content type.

    Declaration
    public IContent CreateAndSave(string name, int parentId, string contentTypeAlias, int userId = -1)
    Parameters
    Type Name Description
    string name

    The name of the content object.

    int parentId

    The identifier of the parent, or -1.

    string contentTypeAlias

    The alias of the content type.

    int userId

    The optional id of the user creating the content.

    Returns
    Type Description
    IContent

    The content object.

    Remarks

    This method returns a new, persisted, IContent with an identity.

    View Source

    CreateAndSave(string, IContent, string, int)

    Creates an IContent object of a specified content type, under a parent.

    Declaration
    public IContent CreateAndSave(string name, IContent parent, string contentTypeAlias, int userId = -1)
    Parameters
    Type Name Description
    string name

    The name of the content object.

    IContent parent

    The parent content object.

    string contentTypeAlias

    The alias of the content type.

    int userId

    The optional id of the user creating the content.

    Returns
    Type Description
    IContent

    The content object.

    Remarks

    This method returns a new, persisted, IContent with an identity.

    View Source

    CreateBlueprintFromContent(IContent, string, int)

    Creates a blueprint from a content item.

    Declaration
    public IContent CreateBlueprintFromContent(IContent blueprint, string name, int userId = -1)
    Parameters
    Type Name Description
    IContent blueprint
    string name
    int userId
    Returns
    Type Description
    IContent
    View Source

    CreateContentFromBlueprint(IContent, string, int)

    (Deprecated) Creates a new content item from a blueprint.

    Declaration
    [Obsolete("Use IContentBlueprintEditingService.GetScaffoldedAsync() instead. Scheduled for removal in V18.")]
    public IContent CreateContentFromBlueprint(IContent blueprint, string name, int userId = -1)
    Parameters
    Type Name Description
    IContent blueprint
    string name
    int userId
    Returns
    Type Description
    IContent
    Remarks

    If creating content from a blueprint, use GetScaffoldedAsync(Guid) instead. If creating a blueprint from content use CreateBlueprintFromContent(IContent, string, int) instead.

    View Source

    Delete(IContent, int)

    Deletes a document.

    Declaration
    public OperationResult Delete(IContent content, int userId = -1)
    Parameters
    Type Name Description
    IContent content
    int userId
    Returns
    Type Description
    OperationResult
    Remarks

    This method will also delete associated media files, child content and possibly associated domains.

    This method entirely clears the content from the database.

    View Source

    DeleteBlueprint(IContent, int)

    Deletes a blueprint.

    Declaration
    public void DeleteBlueprint(IContent content, int userId = -1)
    Parameters
    Type Name Description
    IContent content
    int userId
    View Source

    DeleteBlueprintsOfType(int, int)

    Deletes blueprints for a content type.

    Declaration
    public void DeleteBlueprintsOfType(int contentTypeId, int userId = -1)
    Parameters
    Type Name Description
    int contentTypeId
    int userId
    View Source

    DeleteBlueprintsOfTypes(IEnumerable<int>, int)

    Deletes blueprints for content types.

    Declaration
    public void DeleteBlueprintsOfTypes(IEnumerable<int> contentTypeIds, int userId = -1)
    Parameters
    Type Name Description
    IEnumerable<int> contentTypeIds
    int userId
    View Source

    DeleteOfType(int, int)

    Deletes all content items of specified type. All children of deleted content item is moved to Recycle Bin.

    Declaration
    public void DeleteOfType(int contentTypeId, int userId = -1)
    Parameters
    Type Name Description
    int contentTypeId

    Id of the IContentType

    int userId

    Optional id of the user deleting the media

    Remarks

    This needs extra care and attention as its potentially a dangerous and extensive operation

    View Source

    DeleteOfTypes(IEnumerable<int>, int)

    Deletes all content of specified type. All children of deleted content is moved to Recycle Bin.

    Declaration
    public void DeleteOfTypes(IEnumerable<int> contentTypeIds, int userId = -1)
    Parameters
    Type Name Description
    IEnumerable<int> contentTypeIds

    Id of the IContentType

    int userId

    Optional Id of the user issuing the delete operation

    Remarks

    This needs extra care and attention as its potentially a dangerous and extensive operation.

    Deletes content items of the specified type, and only that type. Does *not* handle content types inheritance and compositions, which need to be managed outside of this method.

    View Source

    DeleteVersion(int, int, bool, int)

    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, int versionId, bool deletePriorVersions, int userId = -1)
    Parameters
    Type Name Description
    int id

    Id of the IContent object to delete a version from

    int versionId

    Id of the version to delete

    bool deletePriorVersions

    Boolean indicating whether to delete versions prior to the versionId

    int userId

    Optional Id of the User deleting versions of a Content object

    View Source

    DeleteVersions(int, DateTime, int)

    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 = -1)
    Parameters
    Type Name Description
    int id

    Id of the IContent object to delete versions from

    DateTime versionDate

    Latest version date

    int userId

    Optional Id of the User deleting versions of a Content object

    View Source

    EmptyRecycleBin(int)

    Empties the Recycle Bin by deleting all IContent that resides in the bin

    Declaration
    public OperationResult EmptyRecycleBin(int userId = -1)
    Parameters
    Type Name Description
    int userId
    Returns
    Type Description
    OperationResult
    View Source

    EmptyRecycleBinAsync(Guid)

    Declaration
    public Task<OperationResult> EmptyRecycleBinAsync(Guid userId)
    Parameters
    Type Name Description
    Guid userId
    Returns
    Type Description
    Task<OperationResult>
    View Source

    GetAncestors(int)

    Gets a collection of IContent objects, which are ancestors of the current content.

    Declaration
    public IEnumerable<IContent> GetAncestors(int id)
    Parameters
    Type Name Description
    int id

    Id of the IContent to retrieve ancestors for

    Returns
    Type Description
    IEnumerable<IContent>

    An Enumerable list of IContent objects

    View Source

    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
    IEnumerable<IContent>

    An Enumerable list of IContent objects

    View Source

    GetBlueprintById(Guid)

    Gets a blueprint.

    Declaration
    public IContent? GetBlueprintById(Guid id)
    Parameters
    Type Name Description
    Guid id
    Returns
    Type Description
    IContent
    View Source

    GetBlueprintById(int)

    Gets a blueprint.

    Declaration
    public IContent? GetBlueprintById(int id)
    Parameters
    Type Name Description
    int id
    Returns
    Type Description
    IContent
    View Source

    GetBlueprintsForContentTypes(params int[])

    Gets blueprints for a content type.

    Declaration
    public IEnumerable<IContent> GetBlueprintsForContentTypes(params int[] contentTypeId)
    Parameters
    Type Name Description
    int[] contentTypeId
    Returns
    Type Description
    IEnumerable<IContent>
    View Source

    GetById(Guid)

    Gets an IContent object by its 'UniqueId'

    Declaration
    public IContent? GetById(Guid key)
    Parameters
    Type Name Description
    Guid key

    Guid key of the Content to retrieve

    Returns
    Type Description
    IContent

    IContent

    View Source

    GetById(int)

    Gets an IContent object by Id

    Declaration
    public IContent? GetById(int id)
    Parameters
    Type Name Description
    int id

    Id of the Content to retrieve

    Returns
    Type Description
    IContent

    IContent

    View Source

    GetByIds(IEnumerable<Guid>)

    Gets IContent objects by Ids

    Declaration
    public IEnumerable<IContent> GetByIds(IEnumerable<Guid> ids)
    Parameters
    Type Name Description
    IEnumerable<Guid> ids

    Ids of the Content to retrieve

    Returns
    Type Description
    IEnumerable<IContent>

    IContent

    View Source

    GetByIds(IEnumerable<int>)

    Gets an IContent object by Id

    Declaration
    public IEnumerable<IContent> GetByIds(IEnumerable<int> ids)
    Parameters
    Type Name Description
    IEnumerable<int> ids

    Ids of the Content to retrieve

    Returns
    Type Description
    IEnumerable<IContent>

    IContent

    View Source

    GetByLevel(int)

    Gets a collection of IContent objects by Level

    Declaration
    public IEnumerable<IContent> GetByLevel(int level)
    Parameters
    Type Name Description
    int level

    The level to retrieve Content from

    Returns
    Type Description
    IEnumerable<IContent>

    An Enumerable list of IContent objects

    Remarks

    Contrary to most methods, this method filters out trashed content items.

    View Source

    GetContentForExpiration(DateTime)

    Gets documents having an expiration date before (lower than, or equal to) a specified date.

    Declaration
    public IEnumerable<IContent> GetContentForExpiration(DateTime date)
    Parameters
    Type Name Description
    DateTime date
    Returns
    Type Description
    IEnumerable<IContent>

    An Enumerable list of IContent objects

    Remarks

    The content returned from this method may be culture variant, in which case you can use GetStatus(IContent, ContentScheduleCollection, string?) to get the status for a specific culture.

    View Source

    GetContentForRelease(DateTime)

    Gets documents having a release date before (lower than, or equal to) a specified date.

    Declaration
    public IEnumerable<IContent> GetContentForRelease(DateTime date)
    Parameters
    Type Name Description
    DateTime date
    Returns
    Type Description
    IEnumerable<IContent>

    An Enumerable list of IContent objects

    Remarks

    The content returned from this method may be culture variant, in which case you can use GetStatus(IContent, ContentScheduleCollection, string?) to get the status for a specific culture.

    View Source

    GetContentScheduleByContentId(Guid)

    Declaration
    public ContentScheduleCollection GetContentScheduleByContentId(Guid contentId)
    Parameters
    Type Name Description
    Guid contentId
    Returns
    Type Description
    ContentScheduleCollection
    View Source

    GetContentScheduleByContentId(int)

    Gets publish/unpublish schedule for a content node.

    Declaration
    public ContentScheduleCollection GetContentScheduleByContentId(int contentId)
    Parameters
    Type Name Description
    int contentId

    Id of the Content to load schedule for

    Returns
    Type Description
    ContentScheduleCollection

    ContentScheduleCollection

    View Source

    GetContentSchedulesByIds(Guid[])

    Gets a dictionary of content Ids and their matching content schedules.

    Declaration
    public IDictionary<int, IEnumerable<ContentSchedule>> GetContentSchedulesByIds(Guid[] keys)
    Parameters
    Type Name Description
    Guid[] keys

    The content keys.

    Returns
    Type Description
    IDictionary<int, IEnumerable<ContentSchedule>>

    A dictionary with a nodeId and an IEnumerable of matching ContentSchedules.

    View Source

    GetPagedChildren(int, long, int, out long, IQuery<IContent>?, Ordering?)

    Gets child documents of a parent.

    Declaration
    public IEnumerable<IContent> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalChildren, IQuery<IContent>? filter = null, Ordering? ordering = null)
    Parameters
    Type Name Description
    int id

    The parent identifier.

    long pageIndex

    The page number.

    int pageSize

    The page size.

    long totalChildren
    IQuery<IContent> filter

    Query filter.

    Ordering ordering

    Ordering infos.

    Returns
    Type Description
    IEnumerable<IContent>
    View Source

    GetPagedContentInRecycleBin(long, int, out long, IQuery<IContent>?, Ordering?)

    Gets a collection of an IContent objects, which resides in the Recycle Bin

    Declaration
    public IEnumerable<IContent> GetPagedContentInRecycleBin(long pageIndex, int pageSize, out long totalRecords, IQuery<IContent>? filter = null, Ordering? ordering = null)
    Parameters
    Type Name Description
    long pageIndex
    int pageSize
    long totalRecords
    IQuery<IContent> filter
    Ordering ordering
    Returns
    Type Description
    IEnumerable<IContent>

    An Enumerable list of IContent objects

    View Source

    GetPagedDescendants(int, long, int, out long, IQuery<IContent>?, Ordering?)

    Gets descendant documents of a given parent.

    Declaration
    public IEnumerable<IContent> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, IQuery<IContent>? filter = null, Ordering? ordering = null)
    Parameters
    Type Name Description
    int id

    The parent identifier.

    long pageIndex

    The page number.

    int pageSize

    The page size.

    long totalChildren
    IQuery<IContent> filter

    Query filter.

    Ordering ordering

    Ordering infos.

    Returns
    Type Description
    IEnumerable<IContent>
    View Source

    GetPagedOfType(int, long, int, out long, IQuery<IContent>?, Ordering?)

    Gets paged documents of a content

    Declaration
    public IEnumerable<IContent> GetPagedOfType(int contentTypeId, long pageIndex, int pageSize, out long totalRecords, IQuery<IContent>? filter = null, Ordering? ordering = null)
    Parameters
    Type Name Description
    int contentTypeId

    The page number.

    long pageIndex

    The page number.

    int pageSize

    The page size.

    long totalRecords

    Total number of documents.

    IQuery<IContent> filter

    Search text filter.

    Ordering ordering

    Ordering infos.

    Returns
    Type Description
    IEnumerable<IContent>
    View Source

    GetPagedOfTypes(int[], long, int, out long, IQuery<IContent>?, Ordering?)

    Gets paged documents for specified content types

    Declaration
    public IEnumerable<IContent> GetPagedOfTypes(int[] contentTypeIds, long pageIndex, int pageSize, out long totalRecords, IQuery<IContent>? filter, Ordering? ordering = null)
    Parameters
    Type Name Description
    int[] contentTypeIds

    The page number.

    long pageIndex

    The page number.

    int pageSize

    The page size.

    long totalRecords

    Total number of documents.

    IQuery<IContent> filter

    Search text filter.

    Ordering ordering

    Ordering infos.

    Returns
    Type Description
    IEnumerable<IContent>
    View Source

    GetParent(int)

    Gets the parent of the current content as an IContent item.

    Declaration
    public IContent? GetParent(int id)
    Parameters
    Type Name Description
    int id

    Id of the IContent to retrieve the parent from

    Returns
    Type Description
    IContent

    Parent IContent object

    View Source

    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

    View Source

    GetPermissions(IContent)

    Returns implicit/inherited permissions assigned to the content item for all user groups

    Declaration
    public EntityPermissionCollection GetPermissions(IContent content)
    Parameters
    Type Name Description
    IContent content
    Returns
    Type Description
    EntityPermissionCollection
    View Source

    GetPublishedChildren(int)

    Gets a collection of published IContent objects by Parent Id

    Declaration
    public IEnumerable<IContent> GetPublishedChildren(int id)
    Parameters
    Type Name Description
    int id

    Id of the Parent to retrieve Children from

    Returns
    Type Description
    IEnumerable<IContent>

    An Enumerable list of published IContent objects

    View Source

    GetRootContent()

    Gets a collection of IContent objects, which reside at the first level / root

    Declaration
    public IEnumerable<IContent> GetRootContent()
    Returns
    Type Description
    IEnumerable<IContent>

    An Enumerable list of IContent objects

    View Source

    GetVersion(int)

    Gets a specific version of an IContent item.

    Declaration
    public IContent? GetVersion(int versionId)
    Parameters
    Type Name Description
    int versionId

    Id of the version to retrieve

    Returns
    Type Description
    IContent

    An IContent item

    View Source

    GetVersionIds(int, int)

    Gets a list of all version Ids for the given content item ordered so latest is first

    Declaration
    public IEnumerable<int> GetVersionIds(int id, int maxRows)
    Parameters
    Type Name Description
    int id
    int maxRows

    The maximum number of rows to return

    Returns
    Type Description
    IEnumerable<int>
    View Source

    GetVersions(int)

    Gets a collection of an IContent objects versions by Id

    Declaration
    public IEnumerable<IContent> GetVersions(int id)
    Parameters
    Type Name Description
    int id
    Returns
    Type Description
    IEnumerable<IContent>

    An Enumerable list of IContent objects

    View Source

    GetVersionsSlim(int, int, int)

    Gets a collection of an IContent objects versions by Id

    Declaration
    public IEnumerable<IContent> GetVersionsSlim(int id, int skip, int take)
    Parameters
    Type Name Description
    int id
    int skip
    int take
    Returns
    Type Description
    IEnumerable<IContent>

    An Enumerable list of IContent objects

    View Source

    HasChildren(int)

    Checks whether an IContent item has any children

    Declaration
    public bool HasChildren(int id)
    Parameters
    Type Name Description
    int id

    Id of the IContent

    Returns
    Type Description
    bool

    True if the content has any children otherwise False

    View Source

    IsPathPublishable(IContent)

    Checks if the passed in IContent can be published based on the ancestors publish state.

    Declaration
    public bool IsPathPublishable(IContent content)
    Parameters
    Type Name Description
    IContent content

    IContent to check if ancestors are published

    Returns
    Type Description
    bool

    True if the Content can be published, otherwise False

    View Source

    IsPathPublished(IContent?)

    Gets a value indicating whether a document is path-published.

    Declaration
    public bool IsPathPublished(IContent? content)
    Parameters
    Type Name Description
    IContent content
    Returns
    Type Description
    bool
    Remarks

    A document is path-published when all its ancestors, and the document itself, are published.

    View Source

    Move(IContent, int, int)

    Moves an IContent object to a new location by changing its parent id.

    Declaration
    public OperationResult Move(IContent content, int parentId, int userId = -1)
    Parameters
    Type Name Description
    IContent content

    The IContent to move

    int parentId

    Id of the Content's new Parent

    int userId

    Optional Id of the User moving the Content

    Returns
    Type Description
    OperationResult
    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.

    View Source

    MoveToRecycleBin(IContent, int)

    Moves a document to the recycle bin.

    Declaration
    public OperationResult MoveToRecycleBin(IContent content, int userId = -1)
    Parameters
    Type Name Description
    IContent content
    int userId
    Returns
    Type Description
    OperationResult
    View Source

    PerformScheduledPublish(DateTime)

    Publishes and unpublishes scheduled documents.

    Declaration
    public IEnumerable<PublishResult> PerformScheduledPublish(DateTime date)
    Parameters
    Type Name Description
    DateTime date
    Returns
    Type Description
    IEnumerable<PublishResult>
    View Source

    PersistContentSchedule(IContent, ContentScheduleCollection)

    Persists publish/unpublish schedule for a content node.

    Declaration
    public void PersistContentSchedule(IContent content, ContentScheduleCollection contentSchedule)
    Parameters
    Type Name Description
    IContent content
    ContentScheduleCollection contentSchedule
    View Source

    Publish(IContent, string[], int)

    Publishes a document.

    Declaration
    public PublishResult Publish(IContent content, string[] cultures, int userId = -1)
    Parameters
    Type Name Description
    IContent content

    The document to publish.

    string[] cultures

    The cultures to publish.

    int userId

    The identifier of the user performing the action.

    Returns
    Type Description
    PublishResult
    Remarks

    When a culture is being published, it includes all varying values along with all invariant values.

    Wildcards (*) can be used as culture identifier to publish all cultures.

    An empty array (or a wildcard) can be passed for culture invariant content.

    View Source

    PublishBranch(IContent, PublishBranchFilter, string[], int)

    Publishes a document branch.

    Declaration
    public IEnumerable<PublishResult> PublishBranch(IContent content, PublishBranchFilter publishBranchFilter, string[] cultures, int userId = -1)
    Parameters
    Type Name Description
    IContent content

    The root document.

    PublishBranchFilter publishBranchFilter

    A value indicating options for force publishing unpublished or re-publishing unchanged content.

    string[] cultures

    The cultures to publish.

    int userId

    The identifier of the user performing the operation.

    Returns
    Type Description
    IEnumerable<PublishResult>
    Remarks

    The root of the branch is always published, regardless of publishBranchFilter.

    View Source

    RecycleBinSmells()

    Returns true if there is any content in the recycle bin

    Declaration
    public bool RecycleBinSmells()
    Returns
    Type Description
    bool
    View Source

    Rollback(int, int, string, int)

    Rolls back the content to a specific version.

    Declaration
    public OperationResult Rollback(int id, int versionId, string culture = "*", int userId = -1)
    Parameters
    Type Name Description
    int id

    The id of the content node.

    int versionId

    The version id to roll back to.

    string culture

    An optional culture to roll back.

    int userId

    The identifier of the user who is performing the roll back.

    Returns
    Type Description
    OperationResult
    Remarks

    When no culture is specified, all cultures are rolled back.

    View Source

    Save(IEnumerable<IContent>, int)

    Saves documents.

    Declaration
    public OperationResult Save(IEnumerable<IContent> contents, int userId = -1)
    Parameters
    Type Name Description
    IEnumerable<IContent> contents
    int userId
    Returns
    Type Description
    OperationResult
    View Source

    Save(IContent, int?, ContentScheduleCollection?)

    Saves a document.

    Declaration
    public OperationResult Save(IContent content, int? userId = null, ContentScheduleCollection? contentSchedule = null)
    Parameters
    Type Name Description
    IContent content
    int? userId
    ContentScheduleCollection contentSchedule
    Returns
    Type Description
    OperationResult
    View Source

    SaveBlueprint(IContent, int)

    Saves a blueprint.

    Declaration
    public void SaveBlueprint(IContent content, int userId = -1)
    Parameters
    Type Name Description
    IContent content
    int userId
    View Source

    SaveBlueprint(IContent, IContent?, int)

    Saves a blueprint.

    Declaration
    public void SaveBlueprint(IContent content, IContent? createdFromContent, int userId = -1)
    Parameters
    Type Name Description
    IContent content
    IContent createdFromContent
    int userId
    View Source

    SendToPublication(IContent?, int)

    Sends an IContent to Publication, which executes handlers and events for the 'Send to Publication' action.

    Declaration
    public bool SendToPublication(IContent? content, int userId = -1)
    Parameters
    Type Name Description
    IContent content

    The IContent to send to publication

    int userId

    Optional Id of the User issuing the send to publication

    Returns
    Type Description
    bool

    True if sending publication was successful otherwise false

    View Source

    SetPermission(IContent, string, IEnumerable<int>)

    Assigns a single permission to the current content item for the specified group ids

    Declaration
    public void SetPermission(IContent entity, string permission, IEnumerable<int> groupIds)
    Parameters
    Type Name Description
    IContent entity
    string permission
    IEnumerable<int> groupIds
    View Source

    SetPermissions(EntityPermissionSet)

    Used to bulk update the permissions set for a content item. This will replace all permissions assigned to an entity with a list of user id & permission pairs.

    Declaration
    public void SetPermissions(EntityPermissionSet permissionSet)
    Parameters
    Type Name Description
    EntityPermissionSet permissionSet
    View Source

    Sort(IEnumerable<int>?, int)

    Sorts a collection of IContent objects by updating the SortOrder according to the ordering of items identified by the ids.

    Declaration
    public OperationResult Sort(IEnumerable<int>? ids, int userId = -1)
    Parameters
    Type Name Description
    IEnumerable<int> ids
    int userId
    Returns
    Type Description
    OperationResult

    Result indicating what action was taken when handling the command.

    Remarks

    Using this method will ensure that the Published-state is maintained upon sorting so the cache is updated accordingly - as needed.

    View Source

    Sort(IEnumerable<IContent>, int)

    Sorts a collection of IContent objects by updating the SortOrder according to the ordering of items in the passed in items.

    Declaration
    public OperationResult Sort(IEnumerable<IContent> items, int userId = -1)
    Parameters
    Type Name Description
    IEnumerable<IContent> items
    int userId
    Returns
    Type Description
    OperationResult

    Result indicating what action was taken when handling the command.

    Remarks

    Using this method will ensure that the Published-state is maintained upon sorting so the cache is updated accordingly - as needed.

    View Source

    Unpublish(IContent, string?, int)

    Unpublishes a document.

    Declaration
    public PublishResult Unpublish(IContent content, string? culture = "*", int userId = -1)
    Parameters
    Type Name Description
    IContent content
    string culture
    int userId
    Returns
    Type Description
    PublishResult
    Remarks

    By default, unpublishes the document as a whole, but it is possible to specify a culture to be unpublished. Depending on whether that culture is mandatory, and other cultures remain published, the document as a whole may or may not remain published.

    If the content type is variant, then culture can be either '*' or an actual culture, but neither null nor empty. If the content type is invariant, then culture can be either '*' or null or empty.

    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX