Interface ITemplateService
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public interface ITemplateService : IServiceMethods
View SourceCreateAsync(String, String, String, Guid, Nullable<Guid>)
Creates a new template
Declaration
Task<Attempt<ITemplate, TemplateOperationStatus>> CreateAsync(string name, string alias, string content, Guid userKey, Guid? templateKey = null)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | Name of the new template | 
| System.String | alias | Alias of the template | 
| System.String | content | View content for the new template | 
| Guid | userKey | Key of the user performing the Create. | 
| System.Nullable<Guid> | templateKey | 
Returns
| Type | Description | 
|---|---|
| Task<Attempt<ITemplate, TemplateOperationStatus>> | 
CreateAsync(ITemplate, Guid)
Creates a new template
Declaration
Task<Attempt<ITemplate, TemplateOperationStatus>> CreateAsync(ITemplate template, Guid userKey)Parameters
| Type | Name | Description | 
|---|---|---|
| ITemplate | template | The new template | 
| Guid | userKey | Key of the user performing the Create. | 
Returns
| Type | Description | 
|---|---|
| Task<Attempt<ITemplate, TemplateOperationStatus>> | 
CreateForContentTypeAsync(String, String, Guid)
Creates a template for a content type
Declaration
Task<Attempt<ITemplate, TemplateOperationStatus>> CreateForContentTypeAsync(string contentTypeAlias, string contentTypeName, Guid userKey)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | contentTypeAlias | |
| System.String | contentTypeName | |
| Guid | userKey | Key of the user performing the Create. | 
Returns
| Type | Description | 
|---|---|
| Task<Attempt<ITemplate, TemplateOperationStatus>> | The template created | 
DeleteAsync(Guid, Guid)
Deletes a template by its key
Declaration
Task<Attempt<ITemplate, TemplateOperationStatus>> DeleteAsync(Guid key, Guid userKey)Parameters
| Type | Name | Description | 
|---|---|---|
| Guid | key | Key of the ITemplate to delete | 
| Guid | userKey | Key of the user performing the Delete. | 
Returns
| Type | Description | 
|---|---|
| Task<Attempt<ITemplate, TemplateOperationStatus>> | True if the template was deleted, false otherwise | 
DeleteAsync(String, Guid)
Deletes a template by its alias
Declaration
Task<Attempt<ITemplate, TemplateOperationStatus>> DeleteAsync(string alias, Guid userKey)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | alias | Alias of the ITemplate to delete | 
| Guid | userKey | Key of the user performing the Delete. | 
Returns
| Type | Description | 
|---|---|
| Task<Attempt<ITemplate, TemplateOperationStatus>> | True if the template was deleted, false otherwise | 
GetAllAsync(Guid[])
Gets a list of all ITemplate objects
Declaration
Task<IEnumerable<ITemplate>> GetAllAsync(Guid[] keys)Parameters
| Type | Name | Description | 
|---|---|---|
| Guid[] | keys | 
Returns
| Type | Description | 
|---|---|
| Task<IEnumerable<ITemplate>> | An enumerable list of ITemplate. | 
GetAllAsync(String[])
Gets a list of all ITemplate objects
Declaration
Task<IEnumerable<ITemplate>> GetAllAsync(params string[] aliases)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String[] | aliases | 
Returns
| Type | Description | 
|---|---|
| Task<IEnumerable<ITemplate>> | An enumerable list of ITemplate. | 
GetAsync(Guid)
Gets a ITemplate object by its guid identifier.
Declaration
Task<ITemplate> GetAsync(Guid id)Parameters
| Type | Name | Description | 
|---|---|---|
| Guid | id | The guid identifier of the template. | 
Returns
| Type | Description | 
|---|---|
| Task<ITemplate> | The ITemplate object matching the identifier, or null. | 
GetAsync(Int32)
Gets a ITemplate object by its identifier.
Declaration
Task<ITemplate> GetAsync(int id)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | id | The identifier of the template. | 
Returns
| Type | Description | 
|---|---|
| Task<ITemplate> | The ITemplate object matching the identifier, or null. | 
GetAsync(String)
Gets a ITemplate object by its alias.
Declaration
Task<ITemplate> GetAsync(string alias)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | alias | The alias of the template. | 
Returns
| Type | Description | 
|---|---|
| Task<ITemplate> | The ITemplate object matching the alias, or null. | 
GetChildrenAsync(Int32)
Gets a list of all ITemplate objects
Declaration
Task<IEnumerable<ITemplate>> GetChildrenAsync(int masterTemplateId)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | masterTemplateId | 
Returns
| Type | Description | 
|---|---|
| Task<IEnumerable<ITemplate>> | An enumerable list of ITemplate objects | 
GetDescendantsAsync(Int32)
Gets the template descendants
Declaration
Task<IEnumerable<ITemplate>> GetDescendantsAsync(int masterTemplateId)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | masterTemplateId | 
Returns
| Type | Description | 
|---|---|
| Task<IEnumerable<ITemplate>> | 
GetFileContentStreamAsync(String)
Gets the content of a template as a stream.
Declaration
Task<Stream> GetFileContentStreamAsync(string filepath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the template. | 
Returns
| Type | Description | 
|---|---|
| Task<Stream> | The content of the template. | 
GetFileSizeAsync(String)
Gets the size of a template.
Declaration
Task<long> GetFileSizeAsync(string filepath)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the template. | 
Returns
| Type | Description | 
|---|---|
| Task<System.Int64> | The size of the template. | 
SetFileContentAsync(String, Stream)
Sets the content of a template.
Declaration
Task SetFileContentAsync(string filepath, Stream content)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filepath | The filesystem path to the template. | 
| Stream | content | The content of the template. | 
Returns
| Type | Description | 
|---|---|
| Task | 
UpdateAsync(ITemplate, Guid)
Updates a ITemplate
Declaration
Task<Attempt<ITemplate, TemplateOperationStatus>> UpdateAsync(ITemplate template, Guid userKey)Parameters
| Type | Name | Description | 
|---|---|---|
| ITemplate | template | ITemplate to update | 
| Guid | userKey | Key of the user saving the template | 
Returns
| Type | Description | 
|---|---|
| Task<Attempt<ITemplate, TemplateOperationStatus>> |