Search Results for

    Show / Hide Table of Contents
    View Source

    Class PartialViewService

    Provides services for managing partial view files in Umbraco.

    Inheritance
    object
    RepositoryService
    FileServiceBase<IPartialViewRepository, IPartialView>
    FileServiceOperationBase<IPartialViewRepository, IPartialView, PartialViewOperationStatus>
    Namespace: Umbraco.Cms.Core.Services
    Assembly: Umbraco.Core.dll
    Syntax
    public class PartialViewService : FileServiceOperationBase<IPartialViewRepository, IPartialView, PartialViewOperationStatus>, IService, IPartialViewService, IBasicFileService<IPartialView>
    Remarks

    This service handles CRUD operations for partial view files (.cshtml) stored in the file system, including creating, updating, renaming, and deleting partial views. It also provides access to partial view snippets that can be used as templates when creating new partial views.

    Constructors

    View Source

    PartialViewService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IPartialViewRepository, ILogger<StylesheetService>, IUserIdKeyResolver, IAuditRepository, PartialViewSnippetCollection)

    Declaration
    [Obsolete("Use the non-obsolete constructor instead. Scheduled for removal in Umbraco 18.")]
    public PartialViewService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IPartialViewRepository repository, ILogger<StylesheetService> logger, IUserIdKeyResolver userIdKeyResolver, IAuditRepository auditRepository, PartialViewSnippetCollection snippetCollection)
    Parameters
    Type Name Description
    ICoreScopeProvider provider
    ILoggerFactory loggerFactory
    IEventMessagesFactory eventMessagesFactory
    IPartialViewRepository repository
    ILogger<StylesheetService> logger
    IUserIdKeyResolver userIdKeyResolver
    IAuditRepository auditRepository
    PartialViewSnippetCollection snippetCollection
    View Source

    PartialViewService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IPartialViewRepository, ILogger<StylesheetService>, IUserIdKeyResolver, IAuditService, IAuditRepository, PartialViewSnippetCollection)

    Declaration
    [Obsolete("Use the non-obsolete constructor instead. Scheduled for removal in Umbraco 18.")]
    public PartialViewService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IPartialViewRepository repository, ILogger<StylesheetService> logger, IUserIdKeyResolver userIdKeyResolver, IAuditService auditService, IAuditRepository auditRepository, PartialViewSnippetCollection snippetCollection)
    Parameters
    Type Name Description
    ICoreScopeProvider provider
    ILoggerFactory loggerFactory
    IEventMessagesFactory eventMessagesFactory
    IPartialViewRepository repository
    ILogger<StylesheetService> logger
    IUserIdKeyResolver userIdKeyResolver
    IAuditService auditService
    IAuditRepository auditRepository
    PartialViewSnippetCollection snippetCollection
    View Source

    PartialViewService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IPartialViewRepository, ILogger<StylesheetService>, IUserIdKeyResolver, IAuditService, PartialViewSnippetCollection)

    Declaration
    [Obsolete("Use the non-obsolete constructor instead. Scheduled for removal in Umbraco 18.")]
    public PartialViewService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IPartialViewRepository repository, ILogger<StylesheetService> logger, IUserIdKeyResolver userIdKeyResolver, IAuditService auditService, PartialViewSnippetCollection snippetCollection)
    Parameters
    Type Name Description
    ICoreScopeProvider provider
    ILoggerFactory loggerFactory
    IEventMessagesFactory eventMessagesFactory
    IPartialViewRepository repository
    ILogger<StylesheetService> logger
    IUserIdKeyResolver userIdKeyResolver
    IAuditService auditService
    PartialViewSnippetCollection snippetCollection
    View Source

    PartialViewService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IPartialViewRepository, ILogger<StylesheetService>, IUserIdKeyResolver, IAuditService, PartialViewSnippetCollection, IOptions<RuntimeSettings>)

    Initializes a new instance of the PartialViewService class.

    Declaration
    [ActivatorUtilitiesConstructor]
    public PartialViewService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IPartialViewRepository repository, ILogger<StylesheetService> logger, IUserIdKeyResolver userIdKeyResolver, IAuditService auditService, PartialViewSnippetCollection snippetCollection, IOptions<RuntimeSettings> runtimeSettings)
    Parameters
    Type Name Description
    ICoreScopeProvider provider

    The core scope provider for managing database transactions.

    ILoggerFactory loggerFactory

    The factory for creating loggers.

    IEventMessagesFactory eventMessagesFactory

    The factory for creating event messages.

    IPartialViewRepository repository

    The repository for partial view file operations.

    ILogger<StylesheetService> logger

    The logger instance for logging operations.

    IUserIdKeyResolver userIdKeyResolver

    The resolver for converting user keys to IDs.

    IAuditService auditService

    The service for audit logging.

    PartialViewSnippetCollection snippetCollection

    The collection of available partial view snippets.

    IOptions<RuntimeSettings> runtimeSettings

    The runtime configuration settings.

    Properties

    View Source

    AllowedFileExtensions

    Gets the allowed file extensions for this file type.

    Declaration
    protected override string[] AllowedFileExtensions { get; }
    Property Value
    Type Description
    string[]
    View Source

    AlreadyExists

    Gets the operation status value representing an entity that already exists.

    Declaration
    protected override PartialViewOperationStatus AlreadyExists { get; }
    Property Value
    Type Description
    PartialViewOperationStatus
    View Source

    CancelledByNotification

    Gets the operation status value representing a cancellation by notification handler.

    Declaration
    protected override PartialViewOperationStatus CancelledByNotification { get; }
    Property Value
    Type Description
    PartialViewOperationStatus
    View Source

    EntityType

    Gets the entity type name used for audit logging.

    Declaration
    protected override string EntityType { get; }
    Property Value
    Type Description
    string
    View Source

    InvalidFileExtension

    Gets the operation status value representing an invalid file extension.

    Declaration
    protected override PartialViewOperationStatus InvalidFileExtension { get; }
    Property Value
    Type Description
    PartialViewOperationStatus
    View Source

    InvalidName

    Gets the operation status value representing an invalid file name.

    Declaration
    protected override PartialViewOperationStatus InvalidName { get; }
    Property Value
    Type Description
    PartialViewOperationStatus
    View Source

    NotFound

    Gets the operation status value representing an entity not found condition.

    Declaration
    protected override PartialViewOperationStatus NotFound { get; }
    Property Value
    Type Description
    PartialViewOperationStatus
    View Source

    ParentNotFound

    Gets the operation status value representing a parent folder not found condition.

    Declaration
    protected override PartialViewOperationStatus ParentNotFound { get; }
    Property Value
    Type Description
    PartialViewOperationStatus
    View Source

    PathTooLong

    Gets the operation status value representing a path that exceeds maximum length.

    Declaration
    protected override PartialViewOperationStatus PathTooLong { get; }
    Property Value
    Type Description
    PartialViewOperationStatus
    View Source

    Success

    Gets the operation status value representing a successful operation.

    Declaration
    protected override PartialViewOperationStatus Success { get; }
    Property Value
    Type Description
    PartialViewOperationStatus

    Methods

    View Source

    CreateAsync(PartialViewCreateModel, Guid)

    Creates a new partial view.

    Declaration
    public Task<Attempt<IPartialView?, PartialViewOperationStatus>> CreateAsync(PartialViewCreateModel createModel, Guid userKey)
    Parameters
    Type Name Description
    PartialViewCreateModel createModel

    PartialViewCreateModel containing the information about the partial view being created.

    Guid userKey

    The key of the user performing the operation.

    Returns
    Type Description
    Task<Attempt<IPartialView, PartialViewOperationStatus>>

    An attempt indicating if the operation was a success as well as a more detailed PartialViewOperationStatus.

    View Source

    CreateEntity(string, string?)

    Creates a new entity instance with the specified path and content.

    Declaration
    protected override IPartialView CreateEntity(string path, string? content)
    Parameters
    Type Name Description
    string path

    The file path for the entity.

    string content

    The optional content of the file.

    Returns
    Type Description
    IPartialView

    A new entity instance.

    View Source

    DeleteAsync(string, Guid)

    Deletes a partial view.

    Declaration
    public Task<PartialViewOperationStatus> DeleteAsync(string path, Guid userKey)
    Parameters
    Type Name Description
    string path

    The path of the partial view to delete.

    Guid userKey

    The key of the user performing the operation.

    Returns
    Type Description
    Task<PartialViewOperationStatus>

    An operation status.

    View Source

    DeletedNotification(IPartialView, EventMessages)

    Creates a deleted notification for the specified entity.

    Declaration
    protected override PartialViewDeletedNotification DeletedNotification(IPartialView target, EventMessages messages)
    Parameters
    Type Name Description
    IPartialView target

    The entity that was deleted.

    EventMessages messages

    The event messages to include.

    Returns
    Type Description
    PartialViewDeletedNotification

    A deleted notification instance.

    View Source

    DeletingNotification(IPartialView, EventMessages)

    Creates a deleting notification for the specified entity.

    Declaration
    protected override PartialViewDeletingNotification DeletingNotification(IPartialView target, EventMessages messages)
    Parameters
    Type Name Description
    IPartialView target

    The entity being deleted.

    EventMessages messages

    The event messages to include.

    Returns
    Type Description
    PartialViewDeletingNotification

    A deleting notification instance.

    View Source

    GetSnippetAsync(string)

    Gets a partial view snippet by ID, returns null if not found.

    Declaration
    public Task<PartialViewSnippet?> GetSnippetAsync(string id)
    Parameters
    Type Name Description
    string id

    The name of the snippet to get.

    Returns
    Type Description
    Task<PartialViewSnippet>

    The partial view snippet, null if not found.

    View Source

    GetSnippetsAsync(int, int)

    Gets all the available partial view snippets.

    Declaration
    public Task<PagedModel<PartialViewSnippetSlim>> GetSnippetsAsync(int skip, int take)
    Parameters
    Type Name Description
    int skip

    Amount to skip.

    int take

    Amount to take.

    Returns
    Type Description
    Task<PagedModel<PartialViewSnippetSlim>>
    View Source

    RenameAsync(string, PartialViewRenameModel, Guid)

    Renames a partial view.

    Declaration
    public Task<Attempt<IPartialView?, PartialViewOperationStatus>> RenameAsync(string path, PartialViewRenameModel renameModel, Guid userKey)
    Parameters
    Type Name Description
    string path

    The path of the partial view to rename.

    PartialViewRenameModel renameModel

    A PartialViewRenameModel with the changes.

    Guid userKey

    The key of the user performing the operation.

    Returns
    Type Description
    Task<Attempt<IPartialView, PartialViewOperationStatus>>

    An attempt indicating if the operation was a success as well as a more detailed PartialViewOperationStatus.

    View Source

    SavedNotification(IPartialView, EventMessages)

    Creates a saved notification for the specified entity.

    Declaration
    protected override PartialViewSavedNotification SavedNotification(IPartialView target, EventMessages messages)
    Parameters
    Type Name Description
    IPartialView target

    The entity that was saved.

    EventMessages messages

    The event messages to include.

    Returns
    Type Description
    PartialViewSavedNotification

    A saved notification instance.

    View Source

    SavingNotification(IPartialView, EventMessages)

    Creates a saving notification for the specified entity.

    Declaration
    protected override PartialViewSavingNotification SavingNotification(IPartialView target, EventMessages messages)
    Parameters
    Type Name Description
    IPartialView target

    The entity being saved.

    EventMessages messages

    The event messages to include.

    Returns
    Type Description
    PartialViewSavingNotification

    A saving notification instance.

    View Source

    UpdateAsync(string, PartialViewUpdateModel, Guid)

    Updates an existing partial view.

    Declaration
    public Task<Attempt<IPartialView?, PartialViewOperationStatus>> UpdateAsync(string path, PartialViewUpdateModel updateModel, Guid userKey)
    Parameters
    Type Name Description
    string path

    The path of the partial view to update.

    PartialViewUpdateModel updateModel

    A PartialViewUpdateModel with the changes.

    Guid userKey

    The key of the user performing the operation.

    Returns
    Type Description
    Task<Attempt<IPartialView, PartialViewOperationStatus>>

    An attempt indicating if the operation was a success as well as a more detailed PartialViewOperationStatus.

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