U4-9250 - Guid the IMacroService

This commit is contained in:
Stephan
2016-12-20 15:28:20 +01:00
parent 38e8e1cf9c
commit b25cb9995f
2 changed files with 29 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using Umbraco.Core.Models;
@@ -15,7 +16,7 @@ namespace Umbraco.Core.Services
/// <param name="alias">Alias to retrieve an <see cref="IMacro"/> for</param>
/// <returns>An <see cref="IMacro"/> object</returns>
IMacro GetByAlias(string alias);
///// <summary>
///// Gets a list all available <see cref="IMacro"/> objects
///// </summary>
@@ -23,10 +24,16 @@ namespace Umbraco.Core.Services
///// <returns>An enumerable list of <see cref="IMacro"/> objects</returns>
//IEnumerable<IMacro> GetAll(params string[] aliases);
IEnumerable<IMacro> GetAll();
IEnumerable<IMacro> GetAll(params int[] ids);
IEnumerable<IMacro> GetAll(params Guid[] ids);
IMacro GetById(int id);
IMacro GetById(Guid id);
/// <summary>
/// Deletes an <see cref="IMacro"/>
/// </summary>

View File

@@ -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<IMacro> GetAll()
{
return GetAll(new int[0]);
}
public IEnumerable<IMacro> GetAll(params int[] ids)
{
using (var repository = RepositoryFactory.CreateMacroRepository(UowProvider.GetUnitOfWork()))
@@ -95,6 +98,14 @@ namespace Umbraco.Core.Services
}
}
public IEnumerable<IMacro> 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<IMacro> GetAllByAliases(IMacroRepository repo, IEnumerable<string> aliases)
//{
// foreach (var alias in aliases)