Cleaning the whole api with the help of the expression rewritter

This commit is contained in:
Zoe Roux 2020-09-13 17:25:03 +02:00
parent 3ad5096d21
commit 00bc1a1732
18 changed files with 113 additions and 1338 deletions

View File

@ -58,244 +58,7 @@ namespace Kyoo.Controllers
Task<Studio> GetStudio(Expression<Func<Studio, bool>> where);
Task<People> GetPerson(Expression<Func<People, bool>> where);
// Get by relations
Task<ICollection<Season>> GetSeasonsFromShow(int showID,
Expression<Func<Season, bool>> where = null,
Sort<Season> sort = default,
Pagination limit = default);
Task<ICollection<Season>> GetSeasonsFromShow(int showID,
[Optional] Expression<Func<Season, bool>> where,
Expression<Func<Season, object>> sort,
Pagination limit = default
) => GetSeasonsFromShow(showID, where, new Sort<Season>(sort), limit);
Task<ICollection<Season>> GetSeasonsFromShow(string showSlug,
Expression<Func<Season, bool>> where = null,
Sort<Season> sort = default,
Pagination limit = default);
Task<ICollection<Season>> GetSeasonsFromShow(string showSlug,
[Optional] Expression<Func<Season, bool>> where,
Expression<Func<Season, object>> sort,
Pagination limit = default
) => GetSeasonsFromShow(showSlug, where, new Sort<Season>(sort), limit);
Task<ICollection<Episode>> GetEpisodesFromShow(int showID,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default);
Task<ICollection<Episode>> GetEpisodesFromShow(int showID,
[Optional] Expression<Func<Episode, bool>> where,
Expression<Func<Episode, object>> sort,
Pagination limit = default
) => GetEpisodesFromShow(showID, where, new Sort<Episode>(sort), limit);
Task<ICollection<Episode>> GetEpisodesFromShow(string showSlug,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default);
Task<ICollection<Episode>> GetEpisodesFromShow(string showSlug,
[Optional] Expression<Func<Episode, bool>> where,
Expression<Func<Episode, object>> sort,
Pagination limit = default
) => GetEpisodesFromShow(showSlug, where, new Sort<Episode>(sort), limit);
Task<ICollection<Episode>> GetEpisodesFromSeason(int seasonID,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default);
Task<ICollection<Episode>> GetEpisodesFromSeason(int seasonID,
[Optional] Expression<Func<Episode, bool>> where,
Expression<Func<Episode, object>> sort,
Pagination limit = default
) => GetEpisodesFromSeason(seasonID, where, new Sort<Episode>(sort), limit);
Task<ICollection<Episode>> GetEpisodesFromSeason(int showID,
int seasonNumber,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default);
Task<ICollection<Episode>> GetEpisodesFromSeason(int showID,
int seasonNumber,
[Optional] Expression<Func<Episode, bool>> where,
Expression<Func<Episode, object>> sort,
Pagination limit = default
) => GetEpisodesFromSeason(showID, seasonNumber, where, new Sort<Episode>(sort), limit);
Task<ICollection<Episode>> GetEpisodesFromSeason(string showSlug,
int seasonNumber,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default);
Task<ICollection<Episode>> GetEpisodesFromSeason(string showSlug,
int seasonNumber,
[Optional] Expression<Func<Episode, bool>> where,
Expression<Func<Episode, object>> sort,
Pagination limit = default
) => GetEpisodesFromSeason(showSlug, seasonNumber, where, new Sort<Episode>(sort), limit);
Task<ICollection<PeopleRole>> GetPeopleFromShow(int showID,
Expression<Func<PeopleRole, bool>> where = null,
Sort<PeopleRole> sort = default,
Pagination limit = default);
Task<ICollection<PeopleRole>> GetPeopleFromShow(int showID,
[Optional] Expression<Func<PeopleRole, bool>> where,
Expression<Func<PeopleRole, object>> sort,
Pagination limit = default
) => GetPeopleFromShow(showID, where, new Sort<PeopleRole>(sort), limit);
Task<ICollection<PeopleRole>> GetPeopleFromShow(string showSlug,
Expression<Func<PeopleRole, bool>> where = null,
Sort<PeopleRole> sort = default,
Pagination limit = default);
Task<ICollection<PeopleRole>> GetPeopleFromShow(string showSlug,
[Optional] Expression<Func<PeopleRole, bool>> where,
Expression<Func<PeopleRole, object>> sort,
Pagination limit = default
) => GetPeopleFromShow(showSlug, where, new Sort<PeopleRole>(sort), limit);
Task<ICollection<Genre>> GetGenresFromShow(int showID,
Expression<Func<Genre, bool>> where = null,
Sort<Genre> sort = default,
Pagination limit = default);
Task<ICollection<Genre>> GetGenresFromShow(int showID,
[Optional] Expression<Func<Genre, bool>> where,
Expression<Func<Genre, object>> sort,
Pagination limit = default
) => GetGenresFromShow(showID, where, new Sort<Genre>(sort), limit);
Task<ICollection<Genre>> GetGenresFromShow(string showSlug,
Expression<Func<Genre, bool>> where = null,
Sort<Genre> sort = default,
Pagination limit = default);
Task<ICollection<Genre>> GetGenresFromShow(string showSlug,
[Optional] Expression<Func<Genre, bool>> where,
Expression<Func<Genre, object>> sort,
Pagination limit = default
) => GetGenresFromShow(showSlug, where, new Sort<Genre>(sort), limit);
Task<ICollection<Track>> GetTracksFromEpisode(int episodeID,
Expression<Func<Track, bool>> where = null,
Sort<Track> sort = default,
Pagination limit = default);
Task<ICollection<Track>> GetTracksFromEpisode(int episodeID,
[Optional] Expression<Func<Track, bool>> where,
Expression<Func<Track, object>> sort,
Pagination limit = default
) => GetTracksFromEpisode(episodeID, where, new Sort<Track>(sort), limit);
Task<ICollection<Track>> GetTracksFromEpisode(int showID,
int seasonNumber,
int episodeNumber,
Expression<Func<Track, bool>> where = null,
Sort<Track> sort = default,
Pagination limit = default);
Task<ICollection<Track>> GetTracksFromEpisode(int showID,
int seasonNumber,
int episodeNumber,
[Optional] Expression<Func<Track, bool>> where,
Expression<Func<Track, object>> sort,
Pagination limit = default
) => GetTracksFromEpisode(showID, seasonNumber, episodeNumber, where, new Sort<Track>(sort), limit);
Task<ICollection<Track>> GetTracksFromEpisode(string showSlug,
int seasonNumber,
int episodeNumber,
Expression<Func<Track, bool>> where = null,
Sort<Track> sort = default,
Pagination limit = default);
Task<ICollection<Track>> GetTracksFromEpisode(string showSlug,
int seasonNumber,
int episodeNumber,
[Optional] Expression<Func<Track, bool>> where,
Expression<Func<Track, object>> sort,
Pagination limit = default
) => GetTracksFromEpisode(showSlug, seasonNumber, episodeNumber, where, new Sort<Track>(sort), limit);
Task<Studio> GetStudioFromShow(int showID);
Task<Studio> GetStudioFromShow(string showSlug);
Task<Show> GetShowFromSeason(int seasonID);
Task<Show> GetShowFromEpisode(int episodeID);
Task<Season> GetSeasonFromEpisode(int episodeID);
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);
Task<ICollection<Show>> GetShowsFromLibrary(int id,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default);
Task<ICollection<Show>> GetShowsFromLibrary(int id,
[Optional] Expression<Func<Show, bool>> where,
Expression<Func<Show, object>> sort,
Pagination limit = default
) => GetShowsFromLibrary(id, where, new Sort<Show>(sort), limit);
Task<ICollection<Show>> GetShowsFromLibrary(string slug,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default);
Task<ICollection<Show>> GetShowsFromLibrary(string slug,
[Optional] Expression<Func<Show, bool>> where,
Expression<Func<Show, object>> sort,
Pagination limit = default
) => GetShowsFromLibrary(slug, where, new Sort<Show>(sort), limit);
Task<ICollection<Collection>> GetCollectionsFromLibrary(int id,
Expression<Func<Collection, bool>> where = null,
Sort<Collection> sort = default,
Pagination limit = default);
Task<ICollection<Collection>> GetCollectionsFromLibrary(int id,
[Optional] Expression<Func<Collection, bool>> where,
Expression<Func<Collection, object>> sort,
Pagination limit = default
) => GetCollectionsFromLibrary(id, where, new Sort<Collection>(sort), limit);
Task<ICollection<Collection>> GetCollectionsFromLibrary(string showSlug,
Expression<Func<Collection, bool>> where = null,
Sort<Collection> sort = default,
Pagination limit = default);
Task<ICollection<Collection>> GetCollectionsFromLibrary(string showSlug,
[Optional] Expression<Func<Collection, bool>> where,
Expression<Func<Collection, object>> sort,
Pagination limit = default
) => GetCollectionsFromLibrary(showSlug, where, new Sort<Collection>(sort), limit);
// Library Items relations
Task<ICollection<LibraryItem>> GetItemsFromLibrary(int id,
Expression<Func<LibraryItem, bool>> where = null,
Sort<LibraryItem> sort = default,
@ -316,46 +79,28 @@ namespace Kyoo.Controllers
Pagination limit = default
) => GetItemsFromLibrary(librarySlug, where, new Sort<LibraryItem>(sort), limit);
Task<ICollection<Show>> GetShowsFromCollection(int id,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
// People Role relations
Task<ICollection<PeopleRole>> GetPeopleFromShow(int showID,
Expression<Func<PeopleRole, bool>> where = null,
Sort<PeopleRole> sort = default,
Pagination limit = default);
Task<ICollection<Show>> GetShowsFromCollection(int id,
[Optional] Expression<Func<Show, bool>> where,
Expression<Func<Show, object>> sort,
Task<ICollection<PeopleRole>> GetPeopleFromShow(int showID,
[Optional] Expression<Func<PeopleRole, bool>> where,
Expression<Func<PeopleRole, object>> sort,
Pagination limit = default
) => GetShowsFromCollection(id, where, new Sort<Show>(sort), limit);
) => GetPeopleFromShow(showID, where, new Sort<PeopleRole>(sort), limit);
Task<ICollection<Show>> GetShowsFromCollection(string slug,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Task<ICollection<PeopleRole>> GetPeopleFromShow(string showSlug,
Expression<Func<PeopleRole, bool>> where = null,
Sort<PeopleRole> sort = default,
Pagination limit = default);
Task<ICollection<Show>> GetShowsFromCollection(string slug,
[Optional] Expression<Func<Show, bool>> where,
Expression<Func<Show, object>> sort,
Task<ICollection<PeopleRole>> GetPeopleFromShow(string showSlug,
[Optional] Expression<Func<PeopleRole, bool>> where,
Expression<Func<PeopleRole, object>> sort,
Pagination limit = default
) => GetShowsFromCollection(slug, where, new Sort<Show>(sort), limit);
Task<ICollection<Library>> GetLibrariesFromCollection(int id,
Expression<Func<Library, bool>> where = null,
Sort<Library> sort = default,
Pagination limit = default);
Task<ICollection<Library>> GetLibrariesFromCollection(int id,
[Optional] Expression<Func<Library, bool>> where,
Expression<Func<Library, object>> sort,
Pagination limit = default
) => GetLibrariesFromCollection(id, where, new Sort<Library>(sort), limit);
Task<ICollection<Library>> GetLibrariesFromCollection(string slug,
Expression<Func<Library, bool>> where = null,
Sort<Library> sort = default,
Pagination limit = default);
Task<ICollection<Library>> GetLibrariesFromCollection(string slug,
[Optional] Expression<Func<Library, bool>> where,
Expression<Func<Library, object>> sort,
Pagination limit = default
) => GetLibrariesFromCollection(slug, where, new Sort<Library>(sort), limit);
) => GetPeopleFromShow(showSlug, where, new Sort<PeopleRole>(sort), limit);
// Show Role relations
Task<ICollection<ShowRole>> GetRolesFromPeople(int showID,
Expression<Func<ShowRole, bool>> where = null,
Sort<ShowRole> sort = default,
@ -376,7 +121,6 @@ namespace Kyoo.Controllers
Pagination limit = default
) => GetRolesFromPeople(showSlug, where, new Sort<ShowRole>(sort), limit);
// Helpers
Task AddShowLink(int showID, int? libraryID, int? collectionID);
Task AddShowLink([NotNull] Show show, Library library, Collection collection);
@ -391,10 +135,10 @@ namespace Kyoo.Controllers
Task<ICollection<Show>> GetShows(Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default);
Task<ICollection<Season>> GetSeasonsFromShow(Expression<Func<Season, bool>> where = null,
Task<ICollection<Season>> GetSeasons(Expression<Func<Season, bool>> where = null,
Sort<Season> sort = default,
Pagination limit = default);
Task<ICollection<Episode>> GetEpisodesFromShow(Expression<Func<Episode, bool>> where = null,
Task<ICollection<Episode>> GetEpisodes(Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default);
Task<ICollection<Track>> GetTracks(Expression<Func<Track, bool>> where = null,
@ -425,14 +169,6 @@ namespace Kyoo.Controllers
Expression<Func<Show, object>> sort,
Pagination limit = default
) => GetShows(where, new Sort<Show>(sort), limit);
Task<ICollection<Season>> GetSeasonsFromShow([Optional] Expression<Func<Season, bool>> where,
Expression<Func<Season, object>> sort,
Pagination limit = default
) => GetSeasonsFromShow(where, new Sort<Season>(sort), limit);
Task<ICollection<Episode>> GetEpisodesFromShow([Optional] Expression<Func<Episode, bool>> where,
Expression<Func<Episode, object>> sort,
Pagination limit = default
) => GetEpisodesFromShow(where, new Sort<Episode>(sort), limit);
Task<ICollection<Track>> GetTracks([Optional] Expression<Func<Track, bool>> where,
Expression<Func<Track, object>> sort,
Pagination limit = default
@ -455,7 +191,7 @@ namespace Kyoo.Controllers
) => GetProviders(where, new Sort<ProviderID>(sort), limit);
// Search
// Search
Task<ICollection<Library>> SearchLibraries(string searchQuery);
Task<ICollection<Collection>> SearchCollections(string searchQuery);
Task<ICollection<Show>> SearchShows(string searchQuery);

View File

@ -110,49 +110,6 @@ namespace Kyoo.Controllers
public interface IShowRepository : IRepository<Show>
{
Task AddShowLink(int showID, int? libraryID, int? collectionID);
Task<ICollection<Show>> GetFromLibrary(int id,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default);
Task<ICollection<Show>> GetFromLibrary(int id,
[Optional] Expression<Func<Show, bool>> where,
Expression<Func<Show, object>> sort,
Pagination limit = default
) => GetFromLibrary(id, where, new Sort<Show>(sort), limit);
Task<ICollection<Show>> GetFromLibrary(string slug,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default);
Task<ICollection<Show>> GetFromLibrary(string slug,
[Optional] Expression<Func<Show, bool>> where,
Expression<Func<Show, object>> sort,
Pagination limit = default
) => GetFromLibrary(slug, where, new Sort<Show>(sort), limit);
Task<ICollection<Show>> GetFromCollection(int id,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default);
Task<ICollection<Show>> GetFromCollection(int id,
[Optional] Expression<Func<Show, bool>> where,
Expression<Func<Show, object>> sort,
Pagination limit = default
) => GetFromCollection(id, where, new Sort<Show>(sort), limit);
Task<ICollection<Show>> GetFromCollection(string slug,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default);
Task<ICollection<Show>> GetFromCollection(string slug,
[Optional] Expression<Func<Show, bool>> where,
Expression<Func<Show, object>> sort,
Pagination limit = default
) => GetFromCollection(slug, where, new Sort<Show>(sort), limit);
Task<Show> GetFromSeason(int seasonID);
Task<Show> GetFromEpisode(int episodeID);
}
public interface ISeasonRepository : IRepository<Season>
@ -160,28 +117,6 @@ namespace Kyoo.Controllers
Task<Season> Get(int showID, int seasonNumber);
Task<Season> Get(string showSlug, int seasonNumber);
Task Delete(string showSlug, int seasonNumber);
Task<ICollection<Season>> GetFromShow(int showID,
Expression<Func<Season, bool>> where = null,
Sort<Season> sort = default,
Pagination limit = default);
Task<ICollection<Season>> GetFromShow(int showID,
[Optional] Expression<Func<Season, bool>> where,
Expression<Func<Season, object>> sort,
Pagination limit = default
) => GetFromShow(showID, where, new Sort<Season>(sort), limit);
Task<ICollection<Season>> GetFromShow(string showSlug,
Expression<Func<Season, bool>> where = null,
Sort<Season> sort = default,
Pagination limit = default);
Task<ICollection<Season>> GetFromShow(string showSlug,
[Optional] Expression<Func<Season, bool>> where,
Expression<Func<Season, object>> sort,
Pagination limit = default
) => GetFromShow(showSlug, where, new Sort<Season>(sort), limit);
Task<Season> GetFromEpisode(int episodeID);
}
public interface IEpisodeRepository : IRepository<Episode>
@ -192,143 +127,10 @@ namespace Kyoo.Controllers
Task<Episode> GetAbsolute(int showID, int absoluteNumber);
Task<Episode> GetAbsolute(string showSlug, int absoluteNumber);
Task Delete(string showSlug, int seasonNumber, int episodeNumber);
Task<ICollection<Episode>> GetFromShow(int showID,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default);
Task<ICollection<Episode>> GetFromShow(int showID,
[Optional] Expression<Func<Episode, bool>> where,
Expression<Func<Episode, object>> sort,
Pagination limit = default
) => GetFromShow(showID, where, new Sort<Episode>(sort), limit);
Task<ICollection<Episode>> GetFromShow(string showSlug,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default);
Task<ICollection<Episode>> GetFromShow(string showSlug,
[Optional] Expression<Func<Episode, bool>> where,
Expression<Func<Episode, object>> sort,
Pagination limit = default
) => GetFromShow(showSlug, where, new Sort<Episode>(sort), limit);
Task<ICollection<Episode>> GetFromSeason(int seasonID,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default);
Task<ICollection<Episode>> GetFromSeason(int seasonID,
[Optional] Expression<Func<Episode, bool>> where,
Expression<Func<Episode, object>> sort,
Pagination limit = default
) => GetFromSeason(seasonID, where, new Sort<Episode>(sort), limit);
Task<ICollection<Episode>> GetFromSeason(int showID,
int seasonNumber,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default);
Task<ICollection<Episode>> GetFromSeason(int showID,
int seasonNumber,
[Optional] Expression<Func<Episode, bool>> where,
Expression<Func<Episode, object>> sort,
Pagination limit = default
) => GetFromSeason(showID, seasonNumber, where, new Sort<Episode>(sort), limit);
Task<ICollection<Episode>> GetFromSeason(string showSlug,
int seasonNumber,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default);
Task<ICollection<Episode>> GetFromSeason(string showSlug,
int seasonNumber,
[Optional] Expression<Func<Episode, bool>> where,
Expression<Func<Episode, object>> sort,
Pagination limit = default
) => GetFromSeason(showSlug, seasonNumber, where, new Sort<Episode>(sort), limit);
}
public interface ITrackRepository : IRepository<Track>
{
Task<ICollection<Track>> GetFromEpisode(int episodeID,
Expression<Func<Track, bool>> where = null,
Sort<Track> sort = default,
Pagination limit = default);
Task<ICollection<Track>> GetFromEpisode(int episodeID,
[Optional] Expression<Func<Track, bool>> where,
Expression<Func<Track, object>> sort,
Pagination limit = default
) => GetFromEpisode(episodeID, where, new Sort<Track>(sort), limit);
Task<ICollection<Track>> GetFromEpisode(int showID,
int seasonNumber,
int episodeNumber,
Expression<Func<Track, bool>> where = null,
Sort<Track> sort = default,
Pagination limit = default);
Task<ICollection<Track>> GetFromEpisode(int showID,
int seasonNumber,
int episodeNumber,
[Optional] Expression<Func<Track, bool>> where,
Expression<Func<Track, object>> sort,
Pagination limit = default
) => GetFromEpisode(showID, seasonNumber, episodeNumber, where, new Sort<Track>(sort), limit);
Task<ICollection<Track>> GetFromEpisode(string showSlug,
int seasonNumber,
int episodeNumber,
Expression<Func<Track, bool>> where = null,
Sort<Track> sort = default,
Pagination limit = default);
Task<ICollection<Track>> GetFromEpisode(string showSlug,
int seasonNumber,
int episodeNumber,
[Optional] Expression<Func<Track, bool>> where,
Expression<Func<Track, object>> sort,
Pagination limit = default
) => GetFromEpisode(showSlug, seasonNumber, episodeNumber, where, new Sort<Track>(sort), limit);
}
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);
Task<ICollection<Library>> GetFromCollection(int id,
Expression<Func<Library, bool>> where = null,
Sort<Library> sort = default,
Pagination limit = default);
Task<ICollection<Library>> GetFromCollection(int id,
[Optional] Expression<Func<Library, bool>> where,
Expression<Func<Library, object>> sort,
Pagination limit = default
) => GetFromCollection(id, where, new Sort<Library>(sort), limit);
Task<ICollection<Library>> GetFromCollection(string slug,
Expression<Func<Library, bool>> where = null,
Sort<Library> sort = default,
Pagination limit = default);
Task<ICollection<Library>> GetFromCollection(string slug,
[Optional] Expression<Func<Library, bool>> where,
Expression<Func<Library, object>> sort,
Pagination limit = default
) => GetFromCollection(slug, where, new Sort<Library>(sort), limit);
}
public interface ITrackRepository : IRepository<Track> { }
public interface ILibraryRepository : IRepository<Library> { }
public interface ILibraryItemRepository : IRepository<LibraryItem>
{
@ -355,77 +157,9 @@ namespace Kyoo.Controllers
) => GetFromLibrary(librarySlug, where, new Sort<LibraryItem>(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);
Task<ICollection<Collection>> GetFromLibrary(int id,
Expression<Func<Collection, bool>> where = null,
Sort<Collection> sort = default,
Pagination limit = default);
Task<ICollection<Collection>> GetFromLibrary(int id,
[Optional] Expression<Func<Collection, bool>> where,
Expression<Func<Collection, object>> sort,
Pagination limit = default
) => GetFromLibrary(id, where, new Sort<Collection>(sort), limit);
Task<ICollection<Collection>> GetFromLibrary(string slug,
Expression<Func<Collection, bool>> where = null,
Sort<Collection> sort = default,
Pagination limit = default);
Task<ICollection<Collection>> GetFromLibrary(string slug,
[Optional] Expression<Func<Collection, bool>> where,
Expression<Func<Collection, object>> sort,
Pagination limit = default
) => GetFromLibrary(slug, where, new Sort<Collection>(sort), limit);
}
public interface IGenreRepository : IRepository<Genre>
{
Task<ICollection<Genre>> GetFromShow(int showID,
Expression<Func<Genre, bool>> where = null,
Sort<Genre> sort = default,
Pagination limit = default);
Task<ICollection<Genre>> GetFromShow(int showID,
[Optional] Expression<Func<Genre, bool>> where,
Expression<Func<Genre, object>> sort,
Pagination limit = default
) => GetFromShow(showID, where, new Sort<Genre>(sort), limit);
Task<ICollection<Genre>> GetFromShow(string showSlug,
Expression<Func<Genre, bool>> where = null,
Sort<Genre> sort = default,
Pagination limit = default);
Task<ICollection<Genre>> GetFromShow(string showSlug,
[Optional] Expression<Func<Genre, bool>> where,
Expression<Func<Genre, object>> sort,
Pagination limit = default
) => GetFromShow(showSlug, where, new Sort<Genre>(sort), limit);
}
public interface IStudioRepository : IRepository<Studio>
{
Task<Studio> GetFromShow(int showID);
Task<Studio> GetFromShow(string showSlug);
}
public interface ICollectionRepository : IRepository<Collection> { }
public interface IGenreRepository : IRepository<Genre> { }
public interface IStudioRepository : IRepository<Studio> { }
public interface IPeopleRepository : IRepository<People>
{
@ -469,5 +203,6 @@ namespace Kyoo.Controllers
Pagination limit = default
) => GetFromPeople(showSlug, where, new Sort<ShowRole>(sort), limit);
}
public interface IProviderRepository : IRepository<ProviderID> {}
}

View File

@ -241,18 +241,18 @@ namespace Kyoo.Controllers
return ShowRepository.GetAll(where, sort, limit);
}
public Task<ICollection<Season>> GetSeasonsFromShow(Expression<Func<Season, bool>> where = null,
public Task<ICollection<Season>> GetSeasons(Expression<Func<Season, bool>> where = null,
Sort<Season> sort = default,
Pagination page = default)
Pagination limit = default)
{
return SeasonRepository.GetAll(where, sort, page);
return SeasonRepository.GetAll(where, sort, limit);
}
public Task<ICollection<Episode>> GetEpisodesFromShow(Expression<Func<Episode, bool>> where = null,
public Task<ICollection<Episode>> GetEpisodes(Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination page = default)
Pagination limit = default)
{
return EpisodeRepository.GetAll(where, sort, page);
return EpisodeRepository.GetAll(where, sort, limit);
}
public Task<ICollection<Track>> GetTracks(Expression<Func<Track, bool>> where = null,
@ -290,213 +290,6 @@ namespace Kyoo.Controllers
return ProviderRepository.GetAll(where, sort, page);
}
public Task<ICollection<Season>> GetSeasonsFromShow(int showID,
Expression<Func<Season, bool>> where = null,
Sort<Season> sort = default,
Pagination limit = default)
{
return SeasonRepository.GetFromShow(showID, where, sort, limit);
}
public Task<ICollection<Season>> GetSeasonsFromShow(string showSlug,
Expression<Func<Season, bool>> where = null,
Sort<Season> sort = default,
Pagination limit = default)
{
return SeasonRepository.GetFromShow(showSlug, where, sort, limit);
}
public Task<ICollection<Episode>> GetEpisodesFromShow(int showID,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default)
{
return EpisodeRepository.GetFromShow(showID, where, sort, limit);
}
public Task<ICollection<Episode>> GetEpisodesFromShow(string showSlug,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default)
{
return EpisodeRepository.GetFromShow(showSlug, where, sort, limit);
}
public Task<ICollection<Episode>> GetEpisodesFromSeason(int seasonID,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default)
{
return EpisodeRepository.GetFromSeason(seasonID, where, sort, limit);
}
public Task<ICollection<Episode>> GetEpisodesFromSeason(int showID,
int seasonNumber,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default)
{
return EpisodeRepository.GetFromSeason(showID, seasonNumber, where, sort, limit);
}
public Task<ICollection<Episode>> GetEpisodesFromSeason(string showSlug,
int seasonNumber,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default)
{
return EpisodeRepository.GetFromSeason(showSlug, seasonNumber, where, sort, limit);
}
public Task<ICollection<PeopleRole>> GetPeopleFromShow(int showID,
Expression<Func<PeopleRole, bool>> where = null,
Sort<PeopleRole> sort = default,
Pagination limit = default)
{
return PeopleRepository.GetFromShow(showID, where, sort, limit);
}
public Task<ICollection<PeopleRole>> GetPeopleFromShow(string showSlug,
Expression<Func<PeopleRole, bool>> where = null,
Sort<PeopleRole> sort = default,
Pagination limit = default)
{
return PeopleRepository.GetFromShow(showSlug, where, sort, limit);
}
public Task<ICollection<Genre>> GetGenresFromShow(int showID,
Expression<Func<Genre, bool>> where = null,
Sort<Genre> sort = default,
Pagination limit = default)
{
return GenreRepository.GetFromShow(showID, where, sort, limit);
}
public Task<ICollection<Genre>> GetGenresFromShow(string showSlug,
Expression<Func<Genre, bool>> where = null,
Sort<Genre> sort = default,
Pagination limit = default)
{
return GenreRepository.GetFromShow(showSlug, where, sort, limit);
}
public Task<ICollection<Track>> GetTracksFromEpisode(int episodeID,
Expression<Func<Track, bool>> where = null,
Sort<Track> sort = default,
Pagination limit = default)
{
return TrackRepository.GetFromEpisode(episodeID, where, sort, limit);
}
public Task<ICollection<Track>> GetTracksFromEpisode(int showID,
int seasonNumber,
int episodeNumber,
Expression<Func<Track, bool>> where = null,
Sort<Track> sort = default,
Pagination limit = default)
{
return TrackRepository.GetFromEpisode(showID, seasonNumber, episodeNumber, where, sort, limit);
}
public Task<ICollection<Track>> GetTracksFromEpisode(string showSlug,
int seasonNumber,
int episodeNumber,
Expression<Func<Track, bool>> where = null,
Sort<Track> sort = default,
Pagination limit = default)
{
return TrackRepository.GetFromEpisode(showSlug, seasonNumber, episodeNumber, where, sort, limit);
}
public Task<Studio> GetStudioFromShow(int showID)
{
return StudioRepository.GetFromShow(showID);
}
public Task<Studio> GetStudioFromShow(string showSlug)
{
return StudioRepository.GetFromShow(showSlug);
}
public Task<Show> GetShowFromSeason(int seasonID)
{
return ShowRepository.GetFromSeason(seasonID);
}
public Task<Show> GetShowFromEpisode(int episodeID)
{
return ShowRepository.GetFromEpisode(episodeID);
}
public Task<Season> GetSeasonFromEpisode(int episodeID)
{
return SeasonRepository.GetFromEpisode(episodeID);
}
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<ICollection<Show>> GetShowsFromLibrary(int id,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default)
{
return ShowRepository.GetFromLibrary(id, where, sort, limit);
}
public Task<ICollection<Show>> GetShowsFromLibrary(string slug,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default)
{
return ShowRepository.GetFromLibrary(slug, where, sort, limit);
}
public Task<ICollection<Collection>> GetCollectionsFromLibrary(int id,
Expression<Func<Collection, bool>> where = null,
Sort<Collection> sort = default,
Pagination limit = default)
{
return CollectionRepository.GetFromLibrary(id, where, sort, limit);
}
public Task<ICollection<Collection>> GetCollectionsFromLibrary(string slug,
Expression<Func<Collection, bool>> where = null,
Sort<Collection> sort = default,
Pagination limit = default)
{
return CollectionRepository.GetFromLibrary(slug, where, sort, limit);
}
public Task<ICollection<LibraryItem>> GetItemsFromLibrary(int id,
Expression<Func<LibraryItem, bool>> where = null,
Sort<LibraryItem> sort = default,
@ -513,36 +306,20 @@ namespace Kyoo.Controllers
return LibraryItemRepository.GetFromLibrary(librarySlug, where, sort, limit);
}
public Task<ICollection<Show>> GetShowsFromCollection(int id,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
public Task<ICollection<PeopleRole>> GetPeopleFromShow(int showID,
Expression<Func<PeopleRole, bool>> where = null,
Sort<PeopleRole> sort = default,
Pagination limit = default)
{
return ShowRepository.GetFromCollection(id, where, sort, limit);
return PeopleRepository.GetFromShow(showID, where, sort, limit);
}
public Task<ICollection<Show>> GetShowsFromCollection(string slug,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
public Task<ICollection<PeopleRole>> GetPeopleFromShow(string showSlug,
Expression<Func<PeopleRole, bool>> where = null,
Sort<PeopleRole> sort = default,
Pagination limit = default)
{
return ShowRepository.GetFromCollection(slug, where, sort, limit);
}
public Task<ICollection<Library>> GetLibrariesFromCollection(int id,
Expression<Func<Library, bool>> where = null,
Sort<Library> sort = default,
Pagination limit = default)
{
return LibraryRepository.GetFromCollection(id, where, sort, limit);
}
public Task<ICollection<Library>> GetLibrariesFromCollection(string slug,
Expression<Func<Library, bool>> where = null,
Sort<Library> sort = default,
Pagination limit = default)
{
return LibraryRepository.GetFromCollection(slug, where, sort, limit);
return PeopleRepository.GetFromShow(showSlug, where, sort, limit);
}
public Task<ICollection<ShowRole>> GetRolesFromPeople(int id,

View File

@ -25,12 +25,14 @@ namespace Kyoo.Models
set => People.Name = value;
}
[ExpressionRewrite(nameof(People) + "."+ nameof(Models.People.Poster))]
public string Poster
{
get => People.Poster;
set => People.Poster = value;
}
[ExpressionRewrite(nameof(People) + "."+ nameof(Models.People.ExternalIDs))]
public IEnumerable<MetadataID> ExternalIDs
{
get => People.ExternalIDs;

View File

@ -4,9 +4,7 @@ using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Kyoo.Models;
using Kyoo.Models.Exceptions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Kyoo.Controllers
{
@ -14,15 +12,11 @@ namespace Kyoo.Controllers
{
private bool _disposed;
private readonly DatabaseContext _database;
private readonly Lazy<IShowRepository> _shows;
private readonly Lazy<ILibraryRepository> _libraries;
protected override Expression<Func<CollectionDE, object>> DefaultSort => x => x.Name;
public CollectionRepository(DatabaseContext database, IServiceProvider services) : base(database)
public CollectionRepository(DatabaseContext database) : base(database)
{
_database = database;
_shows = new Lazy<IShowRepository>(services.GetRequiredService<IShowRepository>);
_libraries = new Lazy<ILibraryRepository>(services.GetRequiredService<ILibraryRepository>);
}
public override void Dispose()
@ -31,10 +25,6 @@ namespace Kyoo.Controllers
return;
_disposed = true;
_database.Dispose();
if (_shows.IsValueCreated)
_shows.Value.Dispose();
if (_libraries.IsValueCreated)
_libraries.Value.Dispose();
}
public override async ValueTask DisposeAsync()
@ -43,10 +33,6 @@ namespace Kyoo.Controllers
return;
_disposed = true;
await _database.DisposeAsync();
if (_shows.IsValueCreated)
await _shows.Value.DisposeAsync();
if (_libraries.IsValueCreated)
await _libraries.Value.DisposeAsync();
}
public override async Task<ICollection<Collection>> Search(string query)
@ -79,71 +65,5 @@ namespace Kyoo.Controllers
_database.Entry(link).State = EntityState.Deleted;
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 => (CollectionDE)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 => (CollectionDE)x.Collection),
where,
sort,
limit);
if (!collections.Any() & await _shows.Value.Get(showSlug) == null)
throw new ItemNotFound();
return collections;
}
public async Task<ICollection<Collection>> GetFromLibrary(int id,
Expression<Func<Collection, bool>> where = null,
Sort<Collection> sort = default,
Pagination limit = default)
{
ICollection<Collection> collections = await ApplyFilters(_database.LibraryLinks
.Where(x => x.LibraryID == id && x.CollectionID != null)
.Select(x => (CollectionDE)x.Collection),
where,
sort,
limit);
if (!collections.Any() && await _libraries.Value.Get(id) == null)
throw new ItemNotFound();
return collections;
}
public async Task<ICollection<Collection>> GetFromLibrary(string slug,
Expression<Func<Collection, bool>> where = null,
Sort<Collection> sort = default,
Pagination limit = default)
{
ICollection<Collection> collections = await ApplyFilters(_database.LibraryLinks
.Where(x => x.Library.Slug == slug && x.CollectionID != null)
.Select(x => (CollectionDE)x.Collection),
where,
sort,
limit);
if (!collections.Any() && await _libraries.Value.Get(slug) == null)
throw new ItemNotFound();
return collections;
}
}
}

View File

@ -15,21 +15,13 @@ namespace Kyoo.Controllers
private bool _disposed;
private readonly DatabaseContext _database;
private readonly IProviderRepository _providers;
private readonly IShowRepository _shows;
private readonly ISeasonRepository _seasons;
protected override Expression<Func<Episode, object>> DefaultSort => x => x.EpisodeNumber;
public EpisodeRepository(DatabaseContext database,
IProviderRepository providers,
IShowRepository shows,
ISeasonRepository seasons)
: base(database)
public EpisodeRepository(DatabaseContext database, IProviderRepository providers) : base(database)
{
_database = database;
_providers = providers;
_shows = shows;
_seasons = seasons;
}
@ -132,80 +124,6 @@ namespace Kyoo.Controllers
}
}
public async Task<ICollection<Episode>> GetFromShow(int showID,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default)
{
ICollection<Episode> episodes = await ApplyFilters(_database.Episodes.Where(x => x.ShowID == showID),
where,
sort,
limit);
if (!episodes.Any() && await _shows.Get(showID) == null)
throw new ItemNotFound();
return episodes;
}
public async Task<ICollection<Episode>> GetFromShow(string showSlug,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default)
{
ICollection<Episode> episodes = await ApplyFilters(_database.Episodes.Where(x => x.Show.Slug == showSlug),
where,
sort,
limit);
if (!episodes.Any() && await _shows.Get(showSlug) == null)
throw new ItemNotFound();
return episodes;
}
public async Task<ICollection<Episode>> GetFromSeason(int seasonID,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default)
{
ICollection<Episode> episodes = await ApplyFilters(_database.Episodes.Where(x => x.SeasonID == seasonID),
where,
sort,
limit);
if (!episodes.Any() && await _seasons.Get(seasonID) == null)
throw new ItemNotFound();
return episodes;
}
public async Task<ICollection<Episode>> GetFromSeason(int showID,
int seasonNumber,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default)
{
ICollection<Episode> episodes = await ApplyFilters(_database.Episodes.Where(x => x.ShowID == showID
&& x.SeasonNumber == seasonNumber),
where,
sort,
limit);
if (!episodes.Any() && await _seasons.Get(showID, seasonNumber) == null)
throw new ItemNotFound();
return episodes;
}
public async Task<ICollection<Episode>> GetFromSeason(string showSlug,
int seasonNumber,
Expression<Func<Episode, bool>> where = null,
Sort<Episode> sort = default,
Pagination limit = default)
{
ICollection<Episode> episodes = await ApplyFilters(_database.Episodes.Where(x => x.Show.Slug == showSlug
&& x.SeasonNumber == seasonNumber),
where,
sort,
limit);
if (!episodes.Any() && await _seasons.Get(showSlug, seasonNumber) == null)
throw new ItemNotFound();
return episodes;
}
public async Task Delete(string showSlug, int seasonNumber, int episodeNumber)
{
Episode obj = await Get(showSlug, seasonNumber, episodeNumber);

View File

@ -14,14 +14,12 @@ namespace Kyoo.Controllers
{
private bool _disposed;
private readonly DatabaseContext _database;
private readonly Lazy<IShowRepository> _shows;
protected override Expression<Func<GenreDE, object>> DefaultSort => x => x.Slug;
public GenreRepository(DatabaseContext database, IServiceProvider services) : base(database)
public GenreRepository(DatabaseContext database) : base(database)
{
_database = database;
_shows = new Lazy<IShowRepository>(services.GetRequiredService<IShowRepository>);
}
public override void Dispose()
@ -30,8 +28,6 @@ namespace Kyoo.Controllers
return;
_disposed = true;
_database.Dispose();
if (_shows.IsValueCreated)
_shows.Value.Dispose();
}
public override async ValueTask DisposeAsync()
@ -40,8 +36,6 @@ namespace Kyoo.Controllers
return;
_disposed = true;
await _database.DisposeAsync();
if (_shows.IsValueCreated)
await _shows.Value.DisposeAsync();
}
public override async Task<ICollection<Genre>> Search(string query)
@ -71,36 +65,5 @@ namespace Kyoo.Controllers
_database.Entry(link).State = EntityState.Deleted;
await _database.SaveChangesAsync();
}
public async Task<ICollection<Genre>> GetFromShow(int showID,
Expression<Func<Genre, bool>> where = null,
Sort<Genre> sort = default,
Pagination limit = default)
{
ICollection<Genre> genres = await ApplyFilters(_database.GenreLinks.Where(x => x.ShowID == showID)
.Select(x => (GenreDE)x.Genre),
where,
sort,
limit);
if (!genres.Any() && await _shows.Value.Get(showID) == null)
throw new ItemNotFound();
return genres;
}
public async Task<ICollection<Genre>> GetFromShow(string showSlug,
Expression<Func<Genre, bool>> where = null,
Sort<Genre> sort = default,
Pagination limit = default)
{
ICollection<Genre> genres = await ApplyFilters(_database.GenreLinks
.Where(x => x.Show.Slug == showSlug)
.Select(x => (GenreDE)x.Genre),
where,
sort,
limit);
if (!genres.Any() && await _shows.Value.Get(showSlug) == null)
throw new ItemNotFound();
return genres;
}
}
}

View File

@ -15,16 +15,14 @@ namespace Kyoo.Controllers
private bool _disposed;
private readonly DatabaseContext _database;
private readonly IProviderRepository _providers;
private readonly Lazy<IShowRepository> _shows;
protected override Expression<Func<LibraryDE, object>> DefaultSort => x => x.ID;
public LibraryRepository(DatabaseContext database, IProviderRepository providers, IServiceProvider services)
public LibraryRepository(DatabaseContext database, IProviderRepository providers)
: base(database)
{
_database = database;
_providers = providers;
_shows = new Lazy<IShowRepository>(services.GetRequiredService<IShowRepository>);
}
public override void Dispose()
@ -34,8 +32,6 @@ namespace Kyoo.Controllers
_disposed = true;
_database.Dispose();
_providers.Dispose();
if (_shows.IsValueCreated)
_shows.Value.Dispose();
}
public override async ValueTask DisposeAsync()
@ -45,8 +41,6 @@ namespace Kyoo.Controllers
_disposed = true;
await _database.DisposeAsync();
await _providers.DisposeAsync();
if (_shows.IsValueCreated)
await _shows.Value.DisposeAsync();
}
public override async Task<ICollection<Library>> Search(string query)
@ -99,69 +93,5 @@ namespace Kyoo.Controllers
_database.Entry(entry).State = EntityState.Deleted;
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 => (LibraryDE)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 => (LibraryDE)x.Library),
where,
sort,
limit);
if (!libraries.Any() && await _shows.Value.Get(showSlug) == null)
throw new ItemNotFound();
return libraries;
}
public async Task<ICollection<Library>> GetFromCollection(int id,
Expression<Func<Library, bool>> where = null,
Sort<Library> sort = default,
Pagination limit = default)
{
ICollection<Library> libraries = await ApplyFilters(_database.LibraryLinks
.Where(x => x.CollectionID == id)
.Select(x => (LibraryDE)x.Library),
where,
sort,
limit);
if (!libraries.Any() && await _shows.Value.Get(id) == null)
throw new ItemNotFound();
return libraries;
}
public async Task<ICollection<Library>> GetFromCollection(string slug,
Expression<Func<Library, bool>> where = null,
Sort<Library> sort = default,
Pagination limit = default)
{
ICollection<Library> libraries = await ApplyFilters(_database.LibraryLinks
.Where(x => x.Collection.Slug == slug)
.Select(x => (LibraryDE)x.Library),
where,
sort,
limit);
if (!libraries.Any() && await _shows.Value.Get(slug) == null)
throw new ItemNotFound();
return libraries;
}
}
}

View File

@ -17,20 +17,17 @@ namespace Kyoo.Controllers
private readonly DatabaseContext _database;
private readonly IProviderRepository _providers;
private readonly Lazy<IEpisodeRepository> _episodes;
private readonly IShowRepository _shows;
protected override Expression<Func<Season, object>> DefaultSort => x => x.SeasonNumber;
public SeasonRepository(DatabaseContext database,
IProviderRepository providers,
IShowRepository shows,
IServiceProvider services)
: base(database)
{
_database = database;
_providers = providers;
_episodes = new Lazy<IEpisodeRepository>(services.GetRequiredService<IEpisodeRepository>);
_shows = shows;
}
@ -111,34 +108,6 @@ namespace Kyoo.Controllers
}
}
public async Task<ICollection<Season>> GetFromShow(int showID,
Expression<Func<Season, bool>> where = null,
Sort<Season> sort = default,
Pagination limit = default)
{
ICollection<Season> seasons = await ApplyFilters(_database.Seasons.Where(x => x.ShowID == showID),
where,
sort,
limit);
if (!seasons.Any() && await _shows.Get(showID) == null)
throw new ItemNotFound();
return seasons;
}
public async Task<ICollection<Season>> GetFromShow(string showSlug,
Expression<Func<Season, bool>> where = null,
Sort<Season> sort = default,
Pagination limit = default)
{
ICollection<Season> seasons = await ApplyFilters(_database.Seasons.Where(x => x.Show.Slug == showSlug),
where,
sort,
limit);
if (!seasons.Any() && await _shows.Get(showSlug) == null)
throw new ItemNotFound();
return seasons;
}
public async Task Delete(string showSlug, int seasonNumber)
{
Season obj = await Get(showSlug, seasonNumber);
@ -161,10 +130,5 @@ namespace Kyoo.Controllers
if (obj.Episodes != null)
await _episodes.Value.DeleteRange(obj.Episodes);
}
public Task<Season> GetFromEpisode(int episodeID)
{
return _database.Seasons.FirstOrDefaultAsync(x => x.Episodes.Any(y => y.ID == episodeID));
}
}
}

View File

@ -4,7 +4,6 @@ using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Kyoo.Models;
using Kyoo.Models.Exceptions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
@ -20,8 +19,6 @@ namespace Kyoo.Controllers
private readonly IProviderRepository _providers;
private readonly Lazy<ISeasonRepository> _seasons;
private readonly Lazy<IEpisodeRepository> _episodes;
private readonly Lazy<ILibraryRepository> _libraries;
private readonly Lazy<ICollectionRepository> _collections;
protected override Expression<Func<ShowDE, object>> DefaultSort => x => x.Title;
public ShowRepository(DatabaseContext database,
@ -39,8 +36,6 @@ namespace Kyoo.Controllers
_providers = providers;
_seasons = new Lazy<ISeasonRepository>(services.GetRequiredService<ISeasonRepository>);
_episodes = new Lazy<IEpisodeRepository>(services.GetRequiredService<IEpisodeRepository>);
_libraries = new Lazy<ILibraryRepository>(services.GetRequiredService<ILibraryRepository>);
_collections = new Lazy<ICollectionRepository>(services.GetRequiredService<ICollectionRepository>);
}
public override void Dispose()
@ -57,10 +52,6 @@ namespace Kyoo.Controllers
_seasons.Value.Dispose();
if (_episodes.IsValueCreated)
_episodes.Value.Dispose();
if (_libraries.IsValueCreated)
_libraries.Value.Dispose();
if (_collections.IsValueCreated)
_collections.Value.Dispose();
}
public override async ValueTask DisposeAsync()
@ -77,10 +68,6 @@ namespace Kyoo.Controllers
await _seasons.Value.DisposeAsync();
if (_episodes.IsValueCreated)
await _episodes.Value.DisposeAsync();
if (_libraries.IsValueCreated)
await _libraries.Value.DisposeAsync();
if (_collections.IsValueCreated)
await _collections.Value.DisposeAsync();
}
public override async Task<ICollection<Show>> Search(string query)
@ -186,83 +173,5 @@ namespace Kyoo.Controllers
if (obj.Episodes != null)
await _episodes.Value.DeleteRange(obj.Episodes);
}
public async Task<ICollection<Show>> GetFromLibrary(int id,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default)
{
ICollection<Show> shows = await ApplyFilters(_database.LibraryLinks
.Where(x => x.LibraryID == id && x.ShowID != null)
.Select(x => (ShowDE)x.Show),
where,
sort,
limit);
if (!shows.Any() && await _libraries.Value.Get(id) == null)
throw new ItemNotFound();
return shows;
}
public async Task<ICollection<Show>> GetFromLibrary(string slug,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default)
{
ICollection<Show> shows = await ApplyFilters(_database.LibraryLinks
.Where(x => x.Library.Slug == slug && x.ShowID != null)
.Select(x => (ShowDE)x.Show),
where,
sort,
limit);
if (!shows.Any() && await _libraries.Value.Get(slug) == null)
throw new ItemNotFound();
return shows;
}
public async Task<ICollection<Show>> GetFromCollection(int id,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default)
{
ICollection<Show> shows = await ApplyFilters(_database.CollectionLinks
.Where(x => x.CollectionID== id)
.Select(x => (ShowDE)x.Show),
where,
sort,
limit);
if (!shows.Any() && await _libraries.Value.Get(id) == null)
throw new ItemNotFound();
return shows;
}
public async Task<ICollection<Show>> GetFromCollection(string slug,
Expression<Func<Show, bool>> where = null,
Sort<Show> sort = default,
Pagination limit = default)
{
ICollection<Show> shows = await ApplyFilters(_database.CollectionLinks
.Where(x => x.Collection.Slug == slug)
.Select(x => (ShowDE)x.Show),
where,
sort,
limit);
if (!shows.Any() && await _libraries.Value.Get(slug) == null)
throw new ItemNotFound();
return shows;
}
public Task<Show> GetFromSeason(int seasonID)
{
return _database.Shows
.FirstOrDefaultAsync(x => x.Seasons.Any(y => y.ID == seasonID))
.Cast<Show>();
}
public Task<Show> GetFromEpisode(int episodeID)
{
return _database.Shows
.FirstOrDefaultAsync(x => x.Episodes.Any(y => y.ID == episodeID))
.Cast<Show>();
}
}
}

View File

@ -4,7 +4,6 @@ using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Kyoo.Models;
using Kyoo.Models.Exceptions;
using Microsoft.EntityFrameworkCore;
namespace Kyoo.Controllers
@ -48,27 +47,5 @@ namespace Kyoo.Controllers
show.StudioID = null;
await _database.SaveChangesAsync();
}
public async Task<Studio> GetFromShow(int showID)
{
Studio studio = await _database.Shows
.Where(x => x.ID == showID)
.Select(x => x.Studio)
.FirstOrDefaultAsync();
if (studio == null && !_database.Shows.Any(x => x.ID == showID))
throw new ItemNotFound();
return studio;
}
public async Task<Studio> GetFromShow(string showSlug)
{
Studio studio = await _database.Shows
.Where(x => x.Slug == showSlug)
.Select(x => x.Studio)
.FirstOrDefaultAsync();
if (studio == null && !_database.Shows.Any(x => x.Slug == showSlug))
throw new ItemNotFound();
return studio;
}
}
}

View File

@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Kyoo.Models;
using Kyoo.Models.Exceptions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Kyoo.Controllers
{
@ -15,14 +12,12 @@ namespace Kyoo.Controllers
{
private bool _disposed;
private readonly DatabaseContext _database;
private readonly Lazy<IEpisodeRepository> _episodes;
protected override Expression<Func<Track, object>> DefaultSort => x => x.ID;
public TrackRepository(DatabaseContext database, IServiceProvider services) : base(database)
public TrackRepository(DatabaseContext database) : base(database)
{
_database = database;
_episodes = new Lazy<IEpisodeRepository>(services.GetRequiredService<IEpisodeRepository>);
}
public override void Dispose()
@ -31,8 +26,6 @@ namespace Kyoo.Controllers
return;
_disposed = true;
_database.Dispose();
if (_episodes.IsValueCreated)
_episodes.Value.Dispose();
}
public override async ValueTask DisposeAsync()
@ -41,8 +34,6 @@ namespace Kyoo.Controllers
return;
_disposed = true;
await _database.DisposeAsync();
if (_episodes.IsValueCreated)
await _episodes.Value.DisposeAsync();
}
public override Task<Track> Get(string slug)
@ -97,55 +88,5 @@ namespace Kyoo.Controllers
_database.Entry(obj).State = EntityState.Deleted;
await _database.SaveChangesAsync();
}
public async Task<ICollection<Track>> GetFromEpisode(int episodeID,
Expression<Func<Track, bool>> where = null,
Sort<Track> sort = default,
Pagination limit = default)
{
ICollection<Track> tracks = await ApplyFilters(_database.Tracks.Where(x => x.EpisodeID == episodeID),
where,
sort,
limit);
if (!tracks.Any() && await _episodes.Value.Get(episodeID) == null)
throw new ItemNotFound();
return tracks;
}
public async Task<ICollection<Track>> GetFromEpisode(int showID,
int seasonNumber,
int episodeNumber,
Expression<Func<Track, bool>> where = null,
Sort<Track> sort = default,
Pagination limit = default)
{
ICollection<Track> tracks = await ApplyFilters(_database.Tracks.Where(x => x.Episode.ShowID == showID
&& x.Episode.SeasonNumber == seasonNumber
&& x.Episode.EpisodeNumber == episodeNumber),
where,
sort,
limit);
if (!tracks.Any() && await _episodes.Value.Get(showID, seasonNumber, episodeNumber) == null)
throw new ItemNotFound();
return tracks;
}
public async Task<ICollection<Track>> GetFromEpisode(string showSlug,
int seasonNumber,
int episodeNumber,
Expression<Func<Track, bool>> where = null,
Sort<Track> sort = default,
Pagination limit = default)
{
ICollection<Track> tracks = await ApplyFilters(_database.Tracks.Where(x => x.Episode.Show.Slug == showSlug
&& x.Episode.SeasonNumber == seasonNumber
&& x.Episode.EpisodeNumber == episodeNumber),
where,
sort,
limit);
if (!tracks.Any() && await _episodes.Value.Get(showSlug, seasonNumber, episodeNumber) == null)
throw new ItemNotFound();
return tracks;
}
}
}

View File

@ -63,7 +63,7 @@ namespace Kyoo.Controllers
if (!Directory.Exists(show.Path))
await libraryManager.DeleteShow(show);
ICollection<Episode> episodes = await libraryManager.GetEpisodesFromShow();
ICollection<Episode> episodes = await libraryManager.GetEpisodes();
ICollection<Library> libraries = argument == null
? await libraryManager.GetLibraries()
: new [] { await libraryManager.GetLibrary(argument)};

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Kyoo.Controllers;
using Kyoo.Models;
using Microsoft.AspNetCore.Mvc;
@ -39,8 +40,8 @@ namespace Kyoo.Api
try
{
ICollection<Show> ressources = await _libraryManager.GetShowsFromCollection(id,
ApiHelper.ParseWhere<Show>(where),
ICollection<Show> ressources = await _libraryManager.GetShows(
ApiHelper.ParseWhere<Show>(where, x => x.Collections.Any(y => y.ID == id)),
new Sort<Show>(sortBy),
new Pagination(limit, afterID));
@ -71,8 +72,8 @@ namespace Kyoo.Api
try
{
ICollection<Show> ressources = await _libraryManager.GetShowsFromCollection(slug,
ApiHelper.ParseWhere<Show>(where),
ICollection<Show> ressources = await _libraryManager.GetShows(
ApiHelper.ParseWhere<Show>(where, x => x.Collections.Any(y => y.Slug == slug)),
new Sort<Show>(sortBy),
new Pagination(limit, afterID));
@ -103,8 +104,8 @@ namespace Kyoo.Api
try
{
ICollection<Library> ressources = await _libraryManager.GetLibrariesFromCollection(id,
ApiHelper.ParseWhere<Library>(where),
ICollection<Library> ressources = await _libraryManager.GetLibraries(
ApiHelper.ParseWhere<Library>(where, x => x.Collections.Any(y => y.ID == id)),
new Sort<Library>(sortBy),
new Pagination(limit, afterID));
@ -135,8 +136,8 @@ namespace Kyoo.Api
try
{
ICollection<Library> ressources = await _libraryManager.GetLibrariesFromCollection(slug,
ApiHelper.ParseWhere<Library>(where),
ICollection<Library> ressources = await _libraryManager.GetLibraries(
ApiHelper.ParseWhere<Library>(where, x => x.Collections.Any(y => y.Slug == slug)),
new Sort<Library>(sortBy),
new Pagination(limit, afterID));

View File

@ -2,6 +2,7 @@
using Kyoo.Models;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Kyoo.CommonApi;
using Kyoo.Controllers;
@ -28,7 +29,7 @@ namespace Kyoo.Api
[Authorize(Policy = "Read")]
public async Task<ActionResult<Show>> GetShow(int episodeID)
{
return await _libraryManager.GetShowFromEpisode(episodeID);
return await _libraryManager.GetShow(x => x.Episodes.Any(y => y.ID == episodeID));
}
[HttpGet("{showSlug}-s{seasonNumber:int}e{episodeNumber:int}/show")]
@ -49,7 +50,7 @@ namespace Kyoo.Api
[Authorize(Policy = "Read")]
public async Task<ActionResult<Season>> GetSeason(int episodeID)
{
return await _libraryManager.GetSeasonFromEpisode(episodeID);
return await _libraryManager.GetSeason(x => x.Episodes.Any(y => y.ID == episodeID));
}
[HttpGet("{showSlug}-s{seasonNumber:int}e{episodeNumber:int}/season")]
@ -81,8 +82,8 @@ namespace Kyoo.Api
try
{
ICollection<Track> ressources = await _libraryManager.GetTracksFromEpisode(episodeID,
ApiHelper.ParseWhere<Track>(where),
ICollection<Track> ressources = await _libraryManager.GetTracks(
ApiHelper.ParseWhere<Track>(where, x => x.Episode.ID == episodeID),
new Sort<Track>(sortBy),
new Pagination(limit, afterID));
@ -115,10 +116,10 @@ namespace Kyoo.Api
try
{
ICollection<Track> ressources = await _libraryManager.GetTracksFromEpisode(showID,
seasonNumber,
episodeNumber,
ApiHelper.ParseWhere<Track>(where),
ICollection<Track> ressources = await _libraryManager.GetTracks(
ApiHelper.ParseWhere<Track>(where, x => x.Episode.ShowID == showID
&& x.Episode.SeasonNumber == seasonNumber
&& x.Episode.EpisodeNumber == episodeNumber),
new Sort<Track>(sortBy),
new Pagination(limit, afterID));
@ -151,10 +152,9 @@ namespace Kyoo.Api
try
{
ICollection<Track> ressources = await _libraryManager.GetTracksFromEpisode(showSlug,
seasonNumber,
episodeNumber,
ApiHelper.ParseWhere<Track>(where),
ICollection<Track> ressources = await _libraryManager.GetTracks(ApiHelper.ParseWhere<Track>(where, x => x.Episode.Show.Slug == showSlug
&& x.Episode.SeasonNumber == seasonNumber
&& x.Episode.EpisodeNumber == episodeNumber),
new Sort<Track>(sortBy),
new Pagination(limit, afterID));

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Kyoo.Controllers;
using Kyoo.Models;
using Microsoft.AspNetCore.Mvc;
@ -50,8 +51,8 @@ namespace Kyoo.Api
try
{
ICollection<Show> ressources = await _libraryManager.GetShowsFromLibrary(id,
ApiHelper.ParseWhere<Show>(where),
ICollection<Show> ressources = await _libraryManager.GetShows(
ApiHelper.ParseWhere<Show>(where, x => x.Libraries.Any(y => y.ID == id)),
new Sort<Show>(sortBy),
new Pagination(limit, afterID));
@ -82,8 +83,8 @@ namespace Kyoo.Api
try
{
ICollection<Show> ressources = await _libraryManager.GetShowsFromLibrary(slug,
ApiHelper.ParseWhere<Show>(where),
ICollection<Show> ressources = await _libraryManager.GetShows(
ApiHelper.ParseWhere<Show>(where, x => x.Libraries.Any(y => y.Slug == slug)),
new Sort<Show>(sortBy),
new Pagination(limit, afterID));
@ -114,8 +115,8 @@ namespace Kyoo.Api
try
{
ICollection<Collection> ressources = await _libraryManager.GetCollectionsFromLibrary(id,
ApiHelper.ParseWhere<Collection>(where),
ICollection<Collection> ressources = await _libraryManager.GetCollections(
ApiHelper.ParseWhere<Collection>(where, x => x.Libraries.Any(y => y.ID == id)),
new Sort<Collection>(sortBy),
new Pagination(limit, afterID));
@ -146,8 +147,8 @@ namespace Kyoo.Api
try
{
ICollection<Collection> ressources = await _libraryManager.GetCollectionsFromLibrary(slug,
ApiHelper.ParseWhere<Collection>(where),
ICollection<Collection> ressources = await _libraryManager.GetCollections(
ApiHelper.ParseWhere<Collection>(where, x => x.Libraries.Any(y => y.Slug == slug)),
new Sort<Collection>(sortBy),
new Pagination(limit, afterID));

View File

@ -7,6 +7,7 @@ using Kyoo.Models;
using Kyoo.Models.Exceptions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using Microsoft.Extensions.Configuration;
namespace Kyoo.Api
@ -39,8 +40,8 @@ namespace Kyoo.Api
try
{
ICollection<Episode> ressources = await _libraryManager.GetEpisodesFromSeason(seasonID,
ApiHelper.ParseWhere<Episode>(where),
ICollection<Episode> ressources = await _libraryManager.GetEpisodes(
ApiHelper.ParseWhere<Episode>(where, x => x.SeasonID == seasonID),
new Sort<Episode>(sortBy),
new Pagination(limit, afterID));
@ -72,9 +73,9 @@ namespace Kyoo.Api
try
{
ICollection<Episode> ressources = await _libraryManager.GetEpisodesFromSeason(showSlug,
seasonNumber,
ApiHelper.ParseWhere<Episode>(where),
ICollection<Episode> ressources = await _libraryManager.GetEpisodes(
ApiHelper.ParseWhere<Episode>(where, x => x.Show.Slug == showSlug
&& x.SeasonNumber == seasonNumber),
new Sort<Episode>(sortBy),
new Pagination(limit, afterID));
@ -106,9 +107,8 @@ namespace Kyoo.Api
try
{
ICollection<Episode> ressources = await _libraryManager.GetEpisodesFromSeason(showID,
seasonNumber,
ApiHelper.ParseWhere<Episode>(where),
ICollection<Episode> ressources = await _libraryManager.GetEpisodes(
ApiHelper.ParseWhere<Episode>(where, x => x.ShowID == showID && x.SeasonNumber == seasonNumber),
new Sort<Episode>(sortBy),
new Pagination(limit, afterID));
@ -128,7 +128,7 @@ namespace Kyoo.Api
[Authorize(Policy = "Read")]
public async Task<ActionResult<Show>> GetShow(int seasonID)
{
return await _libraryManager.GetShowFromSeason(seasonID);
return await _libraryManager.GetShow(x => x.Seasons.Any(y => y.ID == seasonID));
}
[HttpGet("{showSlug}-s{seasonNumber:int}/show")]

View File

@ -2,6 +2,7 @@
using Kyoo.Models;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Kyoo.CommonApi;
using Kyoo.Controllers;
@ -39,8 +40,8 @@ namespace Kyoo.Api
try
{
ICollection<Season> ressources = await _libraryManager.GetSeasonsFromShow(showID,
ApiHelper.ParseWhere<Season>(where),
ICollection<Season> ressources = await _libraryManager.GetSeasons(
ApiHelper.ParseWhere<Season>(where, x => x.ShowID == showID),
new Sort<Season>(sortBy),
new Pagination(limit, afterID));
@ -71,8 +72,8 @@ namespace Kyoo.Api
try
{
ICollection<Season> ressources = await _libraryManager.GetSeasonsFromShow(slug,
ApiHelper.ParseWhere<Season>(where),
ICollection<Season> ressources = await _libraryManager.GetSeasons(
ApiHelper.ParseWhere<Season>(where, x => x.Show.Slug == slug),
new Sort<Season>(sortBy),
new Pagination(limit, afterID));
@ -103,8 +104,8 @@ namespace Kyoo.Api
try
{
ICollection<Episode> ressources = await _libraryManager.GetEpisodesFromShow(showID,
ApiHelper.ParseWhere<Episode>(where),
ICollection<Episode> ressources = await _libraryManager.GetEpisodes(
ApiHelper.ParseWhere<Episode>(where, x => x.ShowID == showID),
new Sort<Episode>(sortBy),
new Pagination(limit, afterID));
@ -135,8 +136,8 @@ namespace Kyoo.Api
try
{
ICollection<Episode> ressources = await _libraryManager.GetEpisodesFromShow(slug,
ApiHelper.ParseWhere<Episode>(where),
ICollection<Episode> ressources = await _libraryManager.GetEpisodes(
ApiHelper.ParseWhere<Episode>(where, x => x.Show.Slug == slug),
new Sort<Episode>(sortBy),
new Pagination(limit, afterID));
@ -229,8 +230,8 @@ namespace Kyoo.Api
try
{
ICollection<Genre> ressources = await _libraryManager.GetGenresFromShow(showID,
ApiHelper.ParseWhere<Genre>(where),
ICollection<Genre> ressources = await _libraryManager.GetGenres(
ApiHelper.ParseWhere<Genre>(where, x => x.Shows.Any(y => y.ID == showID)),
new Sort<Genre>(sortBy),
new Pagination(limit, afterID));
@ -261,8 +262,8 @@ namespace Kyoo.Api
try
{
ICollection<Genre> ressources = await _libraryManager.GetGenresFromShow(slug,
ApiHelper.ParseWhere<Genre>(where),
ICollection<Genre> ressources = await _libraryManager.GetGenres(
ApiHelper.ParseWhere<Genre>(where, x => x.Shows.Any(y => y.Slug == slug)),
new Sort<Genre>(sortBy),
new Pagination(limit, afterID));
@ -284,7 +285,7 @@ namespace Kyoo.Api
{
try
{
return await _libraryManager.GetStudioFromShow(showID);
return await _libraryManager.GetStudio(x => x.Shows.Any(y => y.ID == showID));
}
catch (ItemNotFound)
{
@ -298,7 +299,7 @@ namespace Kyoo.Api
{
try
{
return await _libraryManager.GetStudioFromShow(slug);
return await _libraryManager.GetStudio(x => x.Shows.Any(y => y.Slug == slug));
}
catch (ItemNotFound)
{
@ -321,8 +322,8 @@ namespace Kyoo.Api
try
{
ICollection<Library> ressources = await _libraryManager.GetLibrariesFromShow(showID,
ApiHelper.ParseWhere<Library>(where),
ICollection<Library> ressources = await _libraryManager.GetLibraries(
ApiHelper.ParseWhere<Library>(where, x => x.Shows.Any(y => y.ID == showID)),
new Sort<Library>(sortBy),
new Pagination(limit, afterID));
@ -353,8 +354,8 @@ namespace Kyoo.Api
try
{
ICollection<Library> ressources = await _libraryManager.GetLibrariesFromShow(slug,
ApiHelper.ParseWhere<Library>(where),
ICollection<Library> ressources = await _libraryManager.GetLibraries(
ApiHelper.ParseWhere<Library>(where, x => x.Shows.Any(y => y.Slug == slug)),
new Sort<Library>(sortBy),
new Pagination(limit, afterID));
@ -385,8 +386,8 @@ namespace Kyoo.Api
try
{
ICollection<Collection> ressources = await _libraryManager.GetCollectionsFromShow(showID,
ApiHelper.ParseWhere<Collection>(where),
ICollection<Collection> ressources = await _libraryManager.GetCollections(
ApiHelper.ParseWhere<Collection>(where, x => x.Shows.Any(y => y.ID == showID)),
new Sort<Collection>(sortBy),
new Pagination(limit, afterID));
@ -417,8 +418,8 @@ namespace Kyoo.Api
try
{
ICollection<Collection> ressources = await _libraryManager.GetCollectionsFromShow(slug,
ApiHelper.ParseWhere<Collection>(where),
ICollection<Collection> ressources = await _libraryManager.GetCollections(
ApiHelper.ParseWhere<Collection>(where, x => x.Shows.Any(y => y.Slug == slug)),
new Sort<Collection>(sortBy),
new Pagination(limit, afterID));