|
@@ -1,13 +1,16 @@
|
|
using MediaBrowser.Controller.Collections;
|
|
using MediaBrowser.Controller.Collections;
|
|
|
|
+using MediaBrowser.Controller.Dto;
|
|
|
|
+using MediaBrowser.Model.Querying;
|
|
using ServiceStack;
|
|
using ServiceStack;
|
|
using System;
|
|
using System;
|
|
|
|
+using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace MediaBrowser.Api.Movies
|
|
namespace MediaBrowser.Api.Movies
|
|
{
|
|
{
|
|
[Route("/Collections", "POST", Summary = "Creates a new collection")]
|
|
[Route("/Collections", "POST", Summary = "Creates a new collection")]
|
|
- public class CreateCollection : IReturnVoid
|
|
|
|
|
|
+ public class CreateCollection : IReturn<CollectionCreationResult>
|
|
{
|
|
{
|
|
[ApiMember(Name = "IsLocked", Description = "Whether or not to lock the new collection.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
|
|
[ApiMember(Name = "IsLocked", Description = "Whether or not to lock the new collection.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
|
|
public bool IsLocked { get; set; }
|
|
public bool IsLocked { get; set; }
|
|
@@ -17,6 +20,9 @@ namespace MediaBrowser.Api.Movies
|
|
|
|
|
|
[ApiMember(Name = "ParentId", Description = "Optional - create the collection within a specific folder", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
|
[ApiMember(Name = "ParentId", Description = "Optional - create the collection within a specific folder", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
|
public Guid? ParentId { get; set; }
|
|
public Guid? ParentId { get; set; }
|
|
|
|
+
|
|
|
|
+ [ApiMember(Name = "Ids", Description = "Item Ids to add to the collection", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST", AllowMultiple = true)]
|
|
|
|
+ public string Ids { get; set; }
|
|
}
|
|
}
|
|
|
|
|
|
[Route("/Collections/{Id}/Items", "POST", Summary = "Adds items to a collection")]
|
|
[Route("/Collections/{Id}/Items", "POST", Summary = "Adds items to a collection")]
|
|
@@ -42,22 +48,32 @@ namespace MediaBrowser.Api.Movies
|
|
public class CollectionService : BaseApiService
|
|
public class CollectionService : BaseApiService
|
|
{
|
|
{
|
|
private readonly ICollectionManager _collectionManager;
|
|
private readonly ICollectionManager _collectionManager;
|
|
|
|
+ private readonly IDtoService _dtoService;
|
|
|
|
|
|
- public CollectionService(ICollectionManager collectionManager)
|
|
|
|
|
|
+ public CollectionService(ICollectionManager collectionManager, IDtoService dtoService)
|
|
{
|
|
{
|
|
_collectionManager = collectionManager;
|
|
_collectionManager = collectionManager;
|
|
|
|
+ _dtoService = dtoService;
|
|
}
|
|
}
|
|
|
|
|
|
- public void Post(CreateCollection request)
|
|
|
|
|
|
+ public object Post(CreateCollection request)
|
|
{
|
|
{
|
|
var task = _collectionManager.CreateCollection(new CollectionCreationOptions
|
|
var task = _collectionManager.CreateCollection(new CollectionCreationOptions
|
|
{
|
|
{
|
|
IsLocked = request.IsLocked,
|
|
IsLocked = request.IsLocked,
|
|
Name = request.Name,
|
|
Name = request.Name,
|
|
- ParentId = request.ParentId
|
|
|
|
|
|
+ ParentId = request.ParentId,
|
|
|
|
+ ItemIdList = (request.Ids ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => new Guid(i)).ToList()
|
|
});
|
|
});
|
|
|
|
|
|
- Task.WaitAll(task);
|
|
|
|
|
|
+ var item = task.Result;
|
|
|
|
+
|
|
|
|
+ var dto = _dtoService.GetBaseItemDto(item, new List<ItemFields>());
|
|
|
|
+
|
|
|
|
+ return ToOptimizedResult(new CollectionCreationResult
|
|
|
|
+ {
|
|
|
|
+ Id = dto.Id
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
public void Post(AddToCollection request)
|
|
public void Post(AddToCollection request)
|
|
@@ -74,4 +90,9 @@ namespace MediaBrowser.Api.Movies
|
|
Task.WaitAll(task);
|
|
Task.WaitAll(task);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public class CollectionCreationResult
|
|
|
|
+ {
|
|
|
|
+ public string Id { get; set; }
|
|
|
|
+ }
|
|
}
|
|
}
|