From bca74790caeea8dc00f6d3e910b3f8a0285ac92f Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 3 Nov 2015 14:07:05 +0100 Subject: [PATCH] Implement IFileService.GetTemplate(Guid) --- src/Umbraco.Core/Services/FileService.cs | 26 +++++++++++++++++------ src/Umbraco.Core/Services/IFileService.cs | 19 +++++++++++------ 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Core/Services/FileService.cs b/src/Umbraco.Core/Services/FileService.cs index aa14b1afa0..c3d6c3f2de 100644 --- a/src/Umbraco.Core/Services/FileService.cs +++ b/src/Umbraco.Core/Services/FileService.cs @@ -294,10 +294,10 @@ namespace Umbraco.Core.Services } /// - /// Gets a object by its alias + /// Gets a object by its alias. /// - /// Alias of the template - /// A object + /// The alias of the template. + /// The object matching the alias, or null. public ITemplate GetTemplate(string alias) { using (var repository = _repositoryFactory.CreateTemplateRepository(_dataUowProvider.GetUnitOfWork())) @@ -307,10 +307,10 @@ namespace Umbraco.Core.Services } /// - /// Gets a object by its alias + /// Gets a object by its identifier. /// - /// Id of the template - /// A object + /// The identifer of the template. + /// The object matching the identifier, or null. public ITemplate GetTemplate(int id) { using (var repository = _repositoryFactory.CreateTemplateRepository(_dataUowProvider.GetUnitOfWork())) @@ -319,6 +319,20 @@ namespace Umbraco.Core.Services } } + /// + /// Gets a object by its guid identifier. + /// + /// The guid identifier of the template. + /// The object matching the identifier, or null. + public ITemplate GetTemplate(Guid id) + { + using (var repository = _repositoryFactory.CreateTemplateRepository(_dataUowProvider.GetUnitOfWork())) + { + var query = Query.Builder.Where(x => x.Key == id); + return repository.GetByQuery(query).SingleOrDefault(); + } + } + public IEnumerable GetTemplateDescendants(string alias) { using (var repository = _repositoryFactory.CreateTemplateRepository(_dataUowProvider.GetUnitOfWork())) diff --git a/src/Umbraco.Core/Services/IFileService.cs b/src/Umbraco.Core/Services/IFileService.cs index e56abc71b5..18318de1db 100644 --- a/src/Umbraco.Core/Services/IFileService.cs +++ b/src/Umbraco.Core/Services/IFileService.cs @@ -117,19 +117,26 @@ namespace Umbraco.Core.Services IEnumerable GetTemplates(int masterTemplateId); /// - /// Gets a object by its alias + /// Gets a object by its alias. /// - /// Alias of the template - /// A object + /// The alias of the template. + /// The object matching the alias, or null. ITemplate GetTemplate(string alias); /// - /// Gets a object by its alias + /// Gets a object by its identifier. /// - /// Id of the template - /// A object + /// The identifer of the template. + /// The object matching the identifier, or null. ITemplate GetTemplate(int id); + /// + /// Gets a object by its guid identifier. + /// + /// The guid identifier of the template. + /// The object matching the identifier, or null. + ITemplate GetTemplate(Guid id); + /// /// Gets the template descendants ///