From b25cb9995f25ad4cfcff74734db2fba08beaa1df Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 20 Dec 2016 15:28:20 +0100 Subject: [PATCH] U4-9250 - Guid the IMacroService --- src/Umbraco.Core/Services/IMacroService.cs | 9 ++++++++- src/Umbraco.Core/Services/MacroService.cs | 23 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/Services/IMacroService.cs b/src/Umbraco.Core/Services/IMacroService.cs index a123fb063e..cbe733e156 100644 --- a/src/Umbraco.Core/Services/IMacroService.cs +++ b/src/Umbraco.Core/Services/IMacroService.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using Umbraco.Core.Models; @@ -15,7 +16,7 @@ namespace Umbraco.Core.Services /// Alias to retrieve an for /// An object IMacro GetByAlias(string alias); - + ///// ///// Gets a list all available objects ///// @@ -23,10 +24,16 @@ namespace Umbraco.Core.Services ///// An enumerable list of objects //IEnumerable GetAll(params string[] aliases); + IEnumerable GetAll(); + IEnumerable GetAll(params int[] ids); + IEnumerable GetAll(params Guid[] ids); + IMacro GetById(int id); + IMacro GetById(Guid id); + /// /// Deletes an /// diff --git a/src/Umbraco.Core/Services/MacroService.cs b/src/Umbraco.Core/Services/MacroService.cs index 49853eab81..a6de12ed32 100644 --- a/src/Umbraco.Core/Services/MacroService.cs +++ b/src/Umbraco.Core/Services/MacroService.cs @@ -2,14 +2,12 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; -using Umbraco.Core.Auditing; using Umbraco.Core.Events; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Querying; -using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.UnitOfWork; namespace Umbraco.Core.Services @@ -87,6 +85,11 @@ namespace Umbraco.Core.Services // } //} + public IEnumerable GetAll() + { + return GetAll(new int[0]); + } + public IEnumerable GetAll(params int[] ids) { using (var repository = RepositoryFactory.CreateMacroRepository(UowProvider.GetUnitOfWork())) @@ -95,6 +98,14 @@ namespace Umbraco.Core.Services } } + public IEnumerable GetAll(params Guid[] ids) + { + using (var repository = RepositoryFactory.CreateMacroRepository(UowProvider.GetUnitOfWork())) + { + return repository.GetAll(ids); + } + } + public IMacro GetById(int id) { using (var repository = RepositoryFactory.CreateMacroRepository(UowProvider.GetUnitOfWork())) @@ -103,6 +114,14 @@ namespace Umbraco.Core.Services } } + public IMacro GetById(Guid id) + { + using (var repository = RepositoryFactory.CreateMacroRepository(UowProvider.GetUnitOfWork())) + { + return repository.Get(id); + } + } + //private IEnumerable GetAllByAliases(IMacroRepository repo, IEnumerable aliases) //{ // foreach (var alias in aliases)