mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-02 21:24:20 -04:00
Finishing the show api
This commit is contained in:
parent
1f53affafa
commit
193004a3ee
@ -151,6 +151,46 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
Task<Studio> GetStudioFromShow(int showID);
|
Task<Studio> GetStudioFromShow(int showID);
|
||||||
Task<Studio> GetStudioFromShow(string showSlug);
|
Task<Studio> GetStudioFromShow(string showSlug);
|
||||||
|
|
||||||
|
Task<ICollection<Library>> GetLibrariesFromShow(int showID,
|
||||||
|
Expression<Func<Library, bool>> where = null,
|
||||||
|
Sort<Library> sort = default,
|
||||||
|
Pagination limit = default);
|
||||||
|
Task<ICollection<Library>> GetLibrariesFromShow(int showID,
|
||||||
|
[Optional] Expression<Func<Library, bool>> where,
|
||||||
|
Expression<Func<Library, object>> sort,
|
||||||
|
Pagination limit = default
|
||||||
|
) => GetLibrariesFromShow(showID, where, new Sort<Library>(sort), limit);
|
||||||
|
|
||||||
|
Task<ICollection<Library>> GetLibrariesFromShow(string showSlug,
|
||||||
|
Expression<Func<Library, bool>> where = null,
|
||||||
|
Sort<Library> sort = default,
|
||||||
|
Pagination limit = default);
|
||||||
|
Task<ICollection<Library>> GetLibrariesFromShow(string showSlug,
|
||||||
|
[Optional] Expression<Func<Library, bool>> where,
|
||||||
|
Expression<Func<Library, object>> sort,
|
||||||
|
Pagination limit = default
|
||||||
|
) => GetLibrariesFromShow(showSlug, where, new Sort<Library>(sort), limit);
|
||||||
|
|
||||||
|
Task<ICollection<Collection>> GetCollectionsFromShow(int showID,
|
||||||
|
Expression<Func<Collection, bool>> where = null,
|
||||||
|
Sort<Collection> sort = default,
|
||||||
|
Pagination limit = default);
|
||||||
|
Task<ICollection<Collection>> GetCollectionsFromShow(int showID,
|
||||||
|
[Optional] Expression<Func<Collection, bool>> where,
|
||||||
|
Expression<Func<Collection, object>> sort,
|
||||||
|
Pagination limit = default
|
||||||
|
) => GetCollectionsFromShow(showID, where, new Sort<Collection>(sort), limit);
|
||||||
|
|
||||||
|
Task<ICollection<Collection>> GetCollectionsFromShow(string showSlug,
|
||||||
|
Expression<Func<Collection, bool>> where = null,
|
||||||
|
Sort<Collection> sort = default,
|
||||||
|
Pagination limit = default);
|
||||||
|
Task<ICollection<Collection>> GetCollectionsFromShow(string showSlug,
|
||||||
|
[Optional] Expression<Func<Collection, bool>> where,
|
||||||
|
Expression<Func<Collection, object>> sort,
|
||||||
|
Pagination limit = default
|
||||||
|
) => GetCollectionsFromShow(showSlug, where, new Sort<Collection>(sort), limit);
|
||||||
|
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
|
@ -193,8 +193,52 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
Task<Track> Get(int episodeID, string languageTag, bool isForced);
|
Task<Track> Get(int episodeID, string languageTag, bool isForced);
|
||||||
}
|
}
|
||||||
public interface ILibraryRepository : IRepository<Library> {}
|
|
||||||
public interface ICollectionRepository : IRepository<Collection> {}
|
public interface ILibraryRepository : IRepository<Library>
|
||||||
|
{
|
||||||
|
Task<ICollection<Library>> GetFromShow(int showID,
|
||||||
|
Expression<Func<Library, bool>> where = null,
|
||||||
|
Sort<Library> sort = default,
|
||||||
|
Pagination limit = default);
|
||||||
|
Task<ICollection<Library>> GetFromShow(int showID,
|
||||||
|
[Optional] Expression<Func<Library, bool>> where,
|
||||||
|
Expression<Func<Library, object>> sort,
|
||||||
|
Pagination limit = default
|
||||||
|
) => GetFromShow(showID, where, new Sort<Library>(sort), limit);
|
||||||
|
|
||||||
|
Task<ICollection<Library>> GetFromShow(string showSlug,
|
||||||
|
Expression<Func<Library, bool>> where = null,
|
||||||
|
Sort<Library> sort = default,
|
||||||
|
Pagination limit = default);
|
||||||
|
Task<ICollection<Library>> GetFromShow(string showSlug,
|
||||||
|
[Optional] Expression<Func<Library, bool>> where,
|
||||||
|
Expression<Func<Library, object>> sort,
|
||||||
|
Pagination limit = default
|
||||||
|
) => GetFromShow(showSlug, where, new Sort<Library>(sort), limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ICollectionRepository : IRepository<Collection>
|
||||||
|
{
|
||||||
|
Task<ICollection<Collection>> GetFromShow(int showID,
|
||||||
|
Expression<Func<Collection, bool>> where = null,
|
||||||
|
Sort<Collection> sort = default,
|
||||||
|
Pagination limit = default);
|
||||||
|
Task<ICollection<Collection>> GetFromShow(int showID,
|
||||||
|
[Optional] Expression<Func<Collection, bool>> where,
|
||||||
|
Expression<Func<Collection, object>> sort,
|
||||||
|
Pagination limit = default
|
||||||
|
) => GetFromShow(showID, where, new Sort<Collection>(sort), limit);
|
||||||
|
|
||||||
|
Task<ICollection<Collection>> GetFromShow(string showSlug,
|
||||||
|
Expression<Func<Collection, bool>> where = null,
|
||||||
|
Sort<Collection> sort = default,
|
||||||
|
Pagination limit = default);
|
||||||
|
Task<ICollection<Collection>> GetFromShow(string showSlug,
|
||||||
|
[Optional] Expression<Func<Collection, bool>> where,
|
||||||
|
Expression<Func<Collection, object>> sort,
|
||||||
|
Pagination limit = default
|
||||||
|
) => GetFromShow(showSlug, where, new Sort<Collection>(sort), limit);
|
||||||
|
}
|
||||||
|
|
||||||
public interface IGenreRepository : IRepository<Genre>
|
public interface IGenreRepository : IRepository<Genre>
|
||||||
{
|
{
|
||||||
|
@ -297,6 +297,38 @@ namespace Kyoo.Controllers
|
|||||||
return StudioRepository.GetFromShow(showSlug);
|
return StudioRepository.GetFromShow(showSlug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<ICollection<Library>> GetLibrariesFromShow(int showID,
|
||||||
|
Expression<Func<Library, bool>> where = null,
|
||||||
|
Sort<Library> sort = default,
|
||||||
|
Pagination limit = default)
|
||||||
|
{
|
||||||
|
return LibraryRepository.GetFromShow(showID, where, sort, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<ICollection<Library>> GetLibrariesFromShow(string showSlug,
|
||||||
|
Expression<Func<Library, bool>> where = null,
|
||||||
|
Sort<Library> sort = default,
|
||||||
|
Pagination limit = default)
|
||||||
|
{
|
||||||
|
return LibraryRepository.GetFromShow(showSlug, where, sort, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<ICollection<Collection>> GetCollectionsFromShow(int showID,
|
||||||
|
Expression<Func<Collection, bool>> where = null,
|
||||||
|
Sort<Collection> sort = default,
|
||||||
|
Pagination limit = default)
|
||||||
|
{
|
||||||
|
return CollectionRepository.GetFromShow(showID, where, sort, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<ICollection<Collection>> GetCollectionsFromShow(string showSlug,
|
||||||
|
Expression<Func<Collection, bool>> where = null,
|
||||||
|
Sort<Collection> sort = default,
|
||||||
|
Pagination limit = default)
|
||||||
|
{
|
||||||
|
return CollectionRepository.GetFromShow(showSlug, where, sort, limit);
|
||||||
|
}
|
||||||
|
|
||||||
public Task AddShowLink(int showID, int? libraryID, int? collectionID)
|
public Task AddShowLink(int showID, int? libraryID, int? collectionID)
|
||||||
{
|
{
|
||||||
return ShowRepository.AddShowLink(showID, libraryID, collectionID);
|
return ShowRepository.AddShowLink(showID, libraryID, collectionID);
|
||||||
|
@ -6,19 +6,36 @@ using System.Threading.Tasks;
|
|||||||
using Kyoo.Models;
|
using Kyoo.Models;
|
||||||
using Kyoo.Models.Exceptions;
|
using Kyoo.Models.Exceptions;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Kyoo.Controllers
|
namespace Kyoo.Controllers
|
||||||
{
|
{
|
||||||
public class CollectionRepository : LocalRepository<Collection>, ICollectionRepository
|
public class CollectionRepository : LocalRepository<Collection>, ICollectionRepository
|
||||||
{
|
{
|
||||||
private readonly DatabaseContext _database;
|
private readonly DatabaseContext _database;
|
||||||
|
private readonly Lazy<IShowRepository> _shows;
|
||||||
protected override Expression<Func<Collection, object>> DefaultSort => x => x.Name;
|
protected override Expression<Func<Collection, object>> DefaultSort => x => x.Name;
|
||||||
|
|
||||||
public CollectionRepository(DatabaseContext database) : base(database)
|
public CollectionRepository(DatabaseContext database, IServiceProvider services) : base(database)
|
||||||
{
|
{
|
||||||
_database = database;
|
_database = database;
|
||||||
|
_shows = new Lazy<IShowRepository>(services.GetRequiredService<IShowRepository>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
base.Dispose();
|
||||||
|
if (_shows.IsValueCreated)
|
||||||
|
_shows.Value.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async ValueTask DisposeAsync()
|
||||||
|
{
|
||||||
|
await _database.DisposeAsync();
|
||||||
|
if (_shows.IsValueCreated)
|
||||||
|
await _shows.Value.DisposeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
public override async Task<ICollection<Collection>> Search(string query)
|
public override async Task<ICollection<Collection>> Search(string query)
|
||||||
{
|
{
|
||||||
return await _database.Collections
|
return await _database.Collections
|
||||||
@ -68,5 +85,37 @@ namespace Kyoo.Controllers
|
|||||||
_database.Entry(link).State = EntityState.Deleted;
|
_database.Entry(link).State = EntityState.Deleted;
|
||||||
await _database.SaveChangesAsync();
|
await _database.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<ICollection<Collection>> GetFromShow(int showID,
|
||||||
|
Expression<Func<Collection, bool>> where = null,
|
||||||
|
Sort<Collection> sort = default,
|
||||||
|
Pagination limit = default)
|
||||||
|
{
|
||||||
|
ICollection<Collection> collections = await ApplyFilters(_database.CollectionLinks
|
||||||
|
.Where(x => x.ShowID == showID)
|
||||||
|
.Select(x => x.Collection),
|
||||||
|
where,
|
||||||
|
sort,
|
||||||
|
limit);
|
||||||
|
if (!collections.Any() & await _shows.Value.Get(showID) == null)
|
||||||
|
throw new ItemNotFound();
|
||||||
|
return collections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ICollection<Collection>> GetFromShow(string showSlug,
|
||||||
|
Expression<Func<Collection, bool>> where = null,
|
||||||
|
Sort<Collection> sort = default,
|
||||||
|
Pagination limit = default)
|
||||||
|
{
|
||||||
|
ICollection<Collection> collections = await ApplyFilters(_database.CollectionLinks
|
||||||
|
.Where(x => x.Show.Slug == showSlug)
|
||||||
|
.Select(x => x.Collection),
|
||||||
|
where,
|
||||||
|
sort,
|
||||||
|
limit);
|
||||||
|
if (!collections.Any() & await _shows.Value.Get(showSlug) == null)
|
||||||
|
throw new ItemNotFound();
|
||||||
|
return collections;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,7 +22,20 @@ namespace Kyoo.Controllers
|
|||||||
_database = database;
|
_database = database;
|
||||||
_shows = new Lazy<IShowRepository>(services.GetRequiredService<IShowRepository>);
|
_shows = new Lazy<IShowRepository>(services.GetRequiredService<IShowRepository>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
base.Dispose();
|
||||||
|
if (_shows.IsValueCreated)
|
||||||
|
_shows.Value.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async ValueTask DisposeAsync()
|
||||||
|
{
|
||||||
|
await _database.DisposeAsync();
|
||||||
|
if (_shows.IsValueCreated)
|
||||||
|
await _shows.Value.DisposeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
public override async Task<ICollection<Genre>> Search(string query)
|
public override async Task<ICollection<Genre>> Search(string query)
|
||||||
{
|
{
|
||||||
@ -92,7 +105,8 @@ namespace Kyoo.Controllers
|
|||||||
Sort<Genre> sort = default,
|
Sort<Genre> sort = default,
|
||||||
Pagination limit = default)
|
Pagination limit = default)
|
||||||
{
|
{
|
||||||
ICollection<Genre> genres = await ApplyFilters(_database.GenreLinks.Where(x => x.Show.Slug == showSlug)
|
ICollection<Genre> genres = await ApplyFilters(_database.GenreLinks
|
||||||
|
.Where(x => x.Show.Slug == showSlug)
|
||||||
.Select(x => x.Genre),
|
.Select(x => x.Genre),
|
||||||
where,
|
where,
|
||||||
sort,
|
sort,
|
||||||
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using Kyoo.Models;
|
using Kyoo.Models;
|
||||||
using Kyoo.Models.Exceptions;
|
using Kyoo.Models.Exceptions;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Kyoo.Controllers
|
namespace Kyoo.Controllers
|
||||||
{
|
{
|
||||||
@ -13,26 +14,32 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
private readonly DatabaseContext _database;
|
private readonly DatabaseContext _database;
|
||||||
private readonly IProviderRepository _providers;
|
private readonly IProviderRepository _providers;
|
||||||
|
private readonly Lazy<IShowRepository> _shows;
|
||||||
protected override Expression<Func<Library, object>> DefaultSort => x => x.ID;
|
protected override Expression<Func<Library, object>> DefaultSort => x => x.ID;
|
||||||
|
|
||||||
|
|
||||||
public LibraryRepository(DatabaseContext database, IProviderRepository providers) : base(database)
|
public LibraryRepository(DatabaseContext database, IProviderRepository providers, IServiceProvider services)
|
||||||
|
: base(database)
|
||||||
{
|
{
|
||||||
_database = database;
|
_database = database;
|
||||||
_providers = providers;
|
_providers = providers;
|
||||||
|
_shows = new Lazy<IShowRepository>(services.GetRequiredService<IShowRepository>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
_database.Dispose();
|
_database.Dispose();
|
||||||
_providers.Dispose();
|
_providers.Dispose();
|
||||||
|
if (_shows.IsValueCreated)
|
||||||
|
_shows.Value.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async ValueTask DisposeAsync()
|
public override async ValueTask DisposeAsync()
|
||||||
{
|
{
|
||||||
await _database.DisposeAsync();
|
await _database.DisposeAsync();
|
||||||
await _providers.DisposeAsync();
|
await _providers.DisposeAsync();
|
||||||
|
if (_shows.IsValueCreated)
|
||||||
|
await _shows.Value.DisposeAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<ICollection<Library>> Search(string query)
|
public override async Task<ICollection<Library>> Search(string query)
|
||||||
@ -90,5 +97,37 @@ namespace Kyoo.Controllers
|
|||||||
_database.Entry(entry).State = EntityState.Deleted;
|
_database.Entry(entry).State = EntityState.Deleted;
|
||||||
await _database.SaveChangesAsync();
|
await _database.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<ICollection<Library>> GetFromShow(int showID,
|
||||||
|
Expression<Func<Library, bool>> where = null,
|
||||||
|
Sort<Library> sort = default,
|
||||||
|
Pagination limit = default)
|
||||||
|
{
|
||||||
|
ICollection<Library> libraries = await ApplyFilters(_database.LibraryLinks
|
||||||
|
.Where(x => x.ShowID == showID)
|
||||||
|
.Select(x => x.Library),
|
||||||
|
where,
|
||||||
|
sort,
|
||||||
|
limit);
|
||||||
|
if (!libraries.Any() && await _shows.Value.Get(showID) == null)
|
||||||
|
throw new ItemNotFound();
|
||||||
|
return libraries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ICollection<Library>> GetFromShow(string showSlug,
|
||||||
|
Expression<Func<Library, bool>> where = null,
|
||||||
|
Sort<Library> sort = default,
|
||||||
|
Pagination limit = default)
|
||||||
|
{
|
||||||
|
ICollection<Library> libraries = await ApplyFilters(_database.LibraryLinks
|
||||||
|
.Where(x => x.Show.Slug == showSlug)
|
||||||
|
.Select(x => x.Library),
|
||||||
|
where,
|
||||||
|
sort,
|
||||||
|
limit);
|
||||||
|
if (!libraries.Any() && await _shows.Value.Get(showSlug) == null)
|
||||||
|
throw new ItemNotFound();
|
||||||
|
return libraries;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -314,5 +314,137 @@ namespace Kyoo.Api
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("{showID:int}/library")]
|
||||||
|
[HttpGet("{showID:int}/libraries")]
|
||||||
|
[Authorize(Policy = "Read")]
|
||||||
|
public async Task<ActionResult<Page<Library>>> GetLibraries(int showID,
|
||||||
|
[FromQuery] string sortBy,
|
||||||
|
[FromQuery] int afterID,
|
||||||
|
[FromQuery] Dictionary<string, string> where,
|
||||||
|
[FromQuery] int limit = 30)
|
||||||
|
{
|
||||||
|
where.Remove("showID");
|
||||||
|
where.Remove("sortBy");
|
||||||
|
where.Remove("limit");
|
||||||
|
where.Remove("afterID");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ICollection<Library> ressources = await _libraryManager.GetLibrariesFromShow(showID,
|
||||||
|
ApiHelper.ParseWhere<Library>(where),
|
||||||
|
new Sort<Library>(sortBy),
|
||||||
|
new Pagination(limit, afterID));
|
||||||
|
|
||||||
|
return Page(ressources, limit);
|
||||||
|
}
|
||||||
|
catch (ItemNotFound)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
return BadRequest(new {Error = ex.Message});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{slug}/library")]
|
||||||
|
[HttpGet("{slug}/libraries")]
|
||||||
|
[Authorize(Policy = "Read")]
|
||||||
|
public async Task<ActionResult<Page<Library>>> GetLibraries(string slug,
|
||||||
|
[FromQuery] string sortBy,
|
||||||
|
[FromQuery] int afterID,
|
||||||
|
[FromQuery] Dictionary<string, string> where,
|
||||||
|
[FromQuery] int limit = 30)
|
||||||
|
{
|
||||||
|
where.Remove("slug");
|
||||||
|
where.Remove("sortBy");
|
||||||
|
where.Remove("limit");
|
||||||
|
where.Remove("afterID");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ICollection<Library> ressources = await _libraryManager.GetLibrariesFromShow(slug,
|
||||||
|
ApiHelper.ParseWhere<Library>(where),
|
||||||
|
new Sort<Library>(sortBy),
|
||||||
|
new Pagination(limit, afterID));
|
||||||
|
|
||||||
|
return Page(ressources, limit);
|
||||||
|
}
|
||||||
|
catch (ItemNotFound)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
return BadRequest(new {Error = ex.Message});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{showID:int}/collection")]
|
||||||
|
[HttpGet("{showID:int}/collections")]
|
||||||
|
[Authorize(Policy = "Read")]
|
||||||
|
public async Task<ActionResult<Page<Collection>>> GetCollections(int showID,
|
||||||
|
[FromQuery] string sortBy,
|
||||||
|
[FromQuery] int afterID,
|
||||||
|
[FromQuery] Dictionary<string, string> where,
|
||||||
|
[FromQuery] int limit = 30)
|
||||||
|
{
|
||||||
|
where.Remove("showID");
|
||||||
|
where.Remove("sortBy");
|
||||||
|
where.Remove("limit");
|
||||||
|
where.Remove("afterID");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ICollection<Collection> ressources = await _libraryManager.GetCollectionsFromShow(showID,
|
||||||
|
ApiHelper.ParseWhere<Collection>(where),
|
||||||
|
new Sort<Collection>(sortBy),
|
||||||
|
new Pagination(limit, afterID));
|
||||||
|
|
||||||
|
return Page(ressources, limit);
|
||||||
|
}
|
||||||
|
catch (ItemNotFound)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
return BadRequest(new {Error = ex.Message});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{slug}/collection")]
|
||||||
|
[HttpGet("{slug}/collections")]
|
||||||
|
[Authorize(Policy = "Read")]
|
||||||
|
public async Task<ActionResult<Page<Collection>>> GetCollections(string slug,
|
||||||
|
[FromQuery] string sortBy,
|
||||||
|
[FromQuery] int afterID,
|
||||||
|
[FromQuery] Dictionary<string, string> where,
|
||||||
|
[FromQuery] int limit = 30)
|
||||||
|
{
|
||||||
|
where.Remove("slug");
|
||||||
|
where.Remove("sortBy");
|
||||||
|
where.Remove("limit");
|
||||||
|
where.Remove("afterID");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ICollection<Collection> ressources = await _libraryManager.GetCollectionsFromShow(slug,
|
||||||
|
ApiHelper.ParseWhere<Collection>(where),
|
||||||
|
new Sort<Collection>(sortBy),
|
||||||
|
new Pagination(limit, afterID));
|
||||||
|
|
||||||
|
return Page(ressources, limit);
|
||||||
|
}
|
||||||
|
catch (ItemNotFound)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
return BadRequest(new {Error = ex.Message});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user