Adding GetByIds to mediaService.cs
This commit is contained in:
@@ -206,6 +206,19 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="IMedia"/> object by Id
|
||||
/// </summary>
|
||||
/// <param name="ids">Ids of the Media to retrieve</param>
|
||||
/// <returns><see cref="IMedia"/></returns>
|
||||
internal IEnumerable<IMedia> GetByIds(IEnumerable<int> ids)
|
||||
{
|
||||
using (var repository = _repositoryFactory.CreateMediaRepository(_uowProvider.GetUnitOfWork()))
|
||||
{
|
||||
return repository.GetAll(ids.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="IMedia"/> object by its 'UniqueId'
|
||||
/// </summary>
|
||||
|
||||
@@ -84,6 +84,18 @@ namespace Umbraco.Web.Editors
|
||||
return Mapper.Map<IMedia, MediaItemDisplay>(foundContent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return media for the specified ids
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<MediaItemDisplay> GetByIds([FromUri]int[] ids)
|
||||
{
|
||||
var foundMedia = ((MediaService)Services.MediaService).GetByIds(ids);
|
||||
return foundMedia.Select(Mapper.Map<IMedia, MediaItemDisplay>);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the root media objects
|
||||
/// </summary>
|
||||
|
||||
@@ -303,7 +303,6 @@
|
||||
<Compile Include="Editors\DataTypeValidateAttribute.cs" />
|
||||
<Compile Include="Editors\EntityController.cs" />
|
||||
<Compile Include="Editors\MediaPostValidateAttribute.cs" />
|
||||
<Compile Include="Editors\MediaUploadController.cs" />
|
||||
<Compile Include="Editors\UserController.cs" />
|
||||
<Compile Include="Models\ContentEditing\DataTypeDisplay.cs" />
|
||||
<Compile Include="Models\ContentEditing\DataTypeSave.cs" />
|
||||
|
||||
Reference in New Issue
Block a user