mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-05-30 10:55:16 -04:00
Finishing the library's items route
This commit is contained in:
@@ -12,6 +12,7 @@ namespace Kyoo.Controllers
|
||||
{
|
||||
// Repositories
|
||||
ILibraryRepository LibraryRepository { get; }
|
||||
ILibraryItemRepository LibraryItemRepository { get; }
|
||||
ICollectionRepository CollectionRepository { get; }
|
||||
IShowRepository ShowRepository { get; }
|
||||
ISeasonRepository SeasonRepository { get; }
|
||||
@@ -231,6 +232,28 @@ namespace Kyoo.Controllers
|
||||
Expression<Func<Collection, object>> sort,
|
||||
Pagination limit = default
|
||||
) => GetCollectionsFromLibrary(showSlug, where, new Sort<Collection>(sort), limit);
|
||||
|
||||
Task<ICollection<LibraryItem>> GetItemsFromLibrary(int id,
|
||||
Expression<Func<LibraryItem, bool>> where = null,
|
||||
Sort<LibraryItem> sort = default,
|
||||
Pagination limit = default);
|
||||
|
||||
Task<ICollection<LibraryItem>> GetItemsFromLibrary(int id,
|
||||
[Optional] Expression<Func<LibraryItem, bool>> where,
|
||||
Expression<Func<LibraryItem, object>> sort,
|
||||
Pagination limit = default
|
||||
) => GetItemsFromLibrary(id, where, new Sort<LibraryItem>(sort), limit);
|
||||
|
||||
Task<ICollection<LibraryItem>> GetItemsFromLibrary(string librarySlug,
|
||||
Expression<Func<LibraryItem, bool>> where = null,
|
||||
Sort<LibraryItem> sort = default,
|
||||
Pagination limit = default);
|
||||
|
||||
Task<ICollection<LibraryItem>> GetItemsFromLibrary(string librarySlug,
|
||||
[Optional] Expression<Func<LibraryItem, bool>> where,
|
||||
Expression<Func<LibraryItem, object>> sort,
|
||||
Pagination limit = default
|
||||
) => GetItemsFromLibrary(librarySlug, where, new Sort<LibraryItem>(sort), limit);
|
||||
|
||||
|
||||
// Helpers
|
||||
|
||||
@@ -257,6 +257,31 @@ namespace Kyoo.Controllers
|
||||
) => GetFromShow(showSlug, where, new Sort<Library>(sort), limit);
|
||||
}
|
||||
|
||||
public interface ILibraryItemRepository : IRepository<LibraryItem>
|
||||
{
|
||||
public Task<ICollection<LibraryItem>> GetFromLibrary(int id,
|
||||
Expression<Func<LibraryItem, bool>> where = null,
|
||||
Sort<LibraryItem> sort = default,
|
||||
Pagination limit = default);
|
||||
|
||||
public Task<ICollection<LibraryItem>> GetFromLibrary(int id,
|
||||
[Optional] Expression<Func<LibraryItem, bool>> where,
|
||||
Expression<Func<LibraryItem, object>> sort,
|
||||
Pagination limit = default
|
||||
) => GetFromLibrary(id, where, new Sort<LibraryItem>(sort), limit);
|
||||
|
||||
public Task<ICollection<LibraryItem>> GetFromLibrary(string librarySlug,
|
||||
Expression<Func<LibraryItem, bool>> where = null,
|
||||
Sort<LibraryItem> sort = default,
|
||||
Pagination limit = default);
|
||||
|
||||
public Task<ICollection<LibraryItem>> GetFromLibrary(string librarySlug,
|
||||
[Optional] Expression<Func<LibraryItem, bool>> where,
|
||||
Expression<Func<LibraryItem, object>> sort,
|
||||
Pagination limit = default
|
||||
) => GetFromLibrary(librarySlug, where, new Sort<LibraryItem>(sort), limit);
|
||||
}
|
||||
|
||||
public interface ICollectionRepository : IRepository<Collection>
|
||||
{
|
||||
Task<ICollection<Collection>> GetFromShow(int showID,
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Kyoo.Controllers
|
||||
public class LibraryManager : ILibraryManager
|
||||
{
|
||||
public ILibraryRepository LibraryRepository { get; }
|
||||
public ILibraryItemRepository LibraryItemRepository { get; }
|
||||
public ICollectionRepository CollectionRepository { get; }
|
||||
public IShowRepository ShowRepository { get; }
|
||||
public ISeasonRepository SeasonRepository { get; }
|
||||
@@ -20,6 +21,7 @@ namespace Kyoo.Controllers
|
||||
public IProviderRepository ProviderRepository { get; }
|
||||
|
||||
public LibraryManager(ILibraryRepository libraryRepository,
|
||||
ILibraryItemRepository libraryItemRepository,
|
||||
ICollectionRepository collectionRepository,
|
||||
IShowRepository showRepository,
|
||||
ISeasonRepository seasonRepository,
|
||||
@@ -31,6 +33,7 @@ namespace Kyoo.Controllers
|
||||
IPeopleRepository peopleRepository)
|
||||
{
|
||||
LibraryRepository = libraryRepository;
|
||||
LibraryItemRepository = libraryItemRepository;
|
||||
CollectionRepository = collectionRepository;
|
||||
ShowRepository = showRepository;
|
||||
SeasonRepository = seasonRepository;
|
||||
@@ -361,6 +364,22 @@ namespace Kyoo.Controllers
|
||||
return CollectionRepository.GetFromLibrary(slug, where, sort, limit);
|
||||
}
|
||||
|
||||
public Task<ICollection<LibraryItem>> GetItemsFromLibrary(int id,
|
||||
Expression<Func<LibraryItem, bool>> where = null,
|
||||
Sort<LibraryItem> sort = default,
|
||||
Pagination limit = default)
|
||||
{
|
||||
return LibraryItemRepository.GetFromLibrary(id, where, sort, limit);
|
||||
}
|
||||
|
||||
public Task<ICollection<LibraryItem>> GetItemsFromLibrary(string librarySlug,
|
||||
Expression<Func<LibraryItem, bool>> where = null,
|
||||
Sort<LibraryItem> sort = default,
|
||||
Pagination limit = default)
|
||||
{
|
||||
return LibraryItemRepository.GetFromLibrary(librarySlug, where, sort, limit);
|
||||
}
|
||||
|
||||
public Task AddShowLink(int showID, int? libraryID, int? collectionID)
|
||||
{
|
||||
return ShowRepository.AddShowLink(showID, libraryID, collectionID);
|
||||
|
||||
Reference in New Issue
Block a user