mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-11-04 03:27:14 -05:00 
			
		
		
		
	Merge branch 'contains' into master
This commit is contained in:
		
						commit
						dacfbcd3b2
					
				@ -58,244 +58,7 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
		Task<Studio> GetStudio(Expression<Func<Studio, bool>> where);
 | 
							Task<Studio> GetStudio(Expression<Func<Studio, bool>> where);
 | 
				
			||||||
		Task<People> GetPerson(Expression<Func<People, bool>> where);
 | 
							Task<People> GetPerson(Expression<Func<People, bool>> where);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// Get by relations
 | 
							// Library Items 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);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		Task<ICollection<LibraryItem>> GetItemsFromLibrary(int id,
 | 
							Task<ICollection<LibraryItem>> GetItemsFromLibrary(int id,
 | 
				
			||||||
			Expression<Func<LibraryItem, bool>> where = null,
 | 
								Expression<Func<LibraryItem, bool>> where = null,
 | 
				
			||||||
			Sort<LibraryItem> sort = default,
 | 
								Sort<LibraryItem> sort = default,
 | 
				
			||||||
@ -316,46 +79,28 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			Pagination limit = default
 | 
								Pagination limit = default
 | 
				
			||||||
		) => GetItemsFromLibrary(librarySlug, where, new Sort<LibraryItem>(sort), limit);
 | 
							) => GetItemsFromLibrary(librarySlug, where, new Sort<LibraryItem>(sort), limit);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		Task<ICollection<Show>> GetShowsFromCollection(int id,
 | 
							// People Role relations
 | 
				
			||||||
			Expression<Func<Show, bool>> where = null, 
 | 
							Task<ICollection<PeopleRole>> GetPeopleFromShow(int showID,
 | 
				
			||||||
			Sort<Show> sort = default,
 | 
								Expression<Func<PeopleRole, bool>> where = null, 
 | 
				
			||||||
 | 
								Sort<PeopleRole> sort = default,
 | 
				
			||||||
			Pagination limit = default);
 | 
								Pagination limit = default);
 | 
				
			||||||
		Task<ICollection<Show>> GetShowsFromCollection(int id,
 | 
							Task<ICollection<PeopleRole>> GetPeopleFromShow(int showID,
 | 
				
			||||||
			[Optional] Expression<Func<Show, bool>> where,
 | 
								[Optional] Expression<Func<PeopleRole, bool>> where,
 | 
				
			||||||
			Expression<Func<Show, object>> sort,
 | 
								Expression<Func<PeopleRole, object>> sort,
 | 
				
			||||||
			Pagination limit = default
 | 
								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,
 | 
							Task<ICollection<PeopleRole>> GetPeopleFromShow(string showSlug,
 | 
				
			||||||
			Expression<Func<Show, bool>> where = null, 
 | 
								Expression<Func<PeopleRole, bool>> where = null, 
 | 
				
			||||||
			Sort<Show> sort = default,
 | 
								Sort<PeopleRole> sort = default,
 | 
				
			||||||
			Pagination limit = default);
 | 
								Pagination limit = default);
 | 
				
			||||||
		Task<ICollection<Show>> GetShowsFromCollection(string slug,
 | 
							Task<ICollection<PeopleRole>> GetPeopleFromShow(string showSlug,
 | 
				
			||||||
			[Optional] Expression<Func<Show, bool>> where,
 | 
								[Optional] Expression<Func<PeopleRole, bool>> where,
 | 
				
			||||||
			Expression<Func<Show, object>> sort,
 | 
								Expression<Func<PeopleRole, object>> sort,
 | 
				
			||||||
			Pagination limit = default
 | 
								Pagination limit = default
 | 
				
			||||||
		) => GetShowsFromCollection(slug, where, new Sort<Show>(sort), limit);
 | 
							) => GetPeopleFromShow(showSlug, where, new Sort<PeopleRole>(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);
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
							// Show Role relations
 | 
				
			||||||
		Task<ICollection<ShowRole>> GetRolesFromPeople(int showID,
 | 
							Task<ICollection<ShowRole>> GetRolesFromPeople(int showID,
 | 
				
			||||||
			Expression<Func<ShowRole, bool>> where = null, 
 | 
								Expression<Func<ShowRole, bool>> where = null, 
 | 
				
			||||||
			Sort<ShowRole> sort = default,
 | 
								Sort<ShowRole> sort = default,
 | 
				
			||||||
@ -376,7 +121,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			Pagination limit = default
 | 
								Pagination limit = default
 | 
				
			||||||
		) => GetRolesFromPeople(showSlug, where, new Sort<ShowRole>(sort), limit);
 | 
							) => GetRolesFromPeople(showSlug, where, new Sort<ShowRole>(sort), limit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
		// Helpers
 | 
							// Helpers
 | 
				
			||||||
		Task AddShowLink(int showID, int? libraryID, int? collectionID);
 | 
							Task AddShowLink(int showID, int? libraryID, int? collectionID);
 | 
				
			||||||
		Task AddShowLink([NotNull] Show show, Library library, Collection collection);
 | 
							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, 
 | 
							Task<ICollection<Show>> GetShows(Expression<Func<Show, bool>> where = null, 
 | 
				
			||||||
			Sort<Show> sort = default,
 | 
								Sort<Show> sort = default,
 | 
				
			||||||
			Pagination limit = 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,
 | 
								Sort<Season> sort = default,
 | 
				
			||||||
			Pagination limit = 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,
 | 
								Sort<Episode> sort = default,
 | 
				
			||||||
			Pagination limit = default);
 | 
								Pagination limit = default);
 | 
				
			||||||
		Task<ICollection<Track>> GetTracks(Expression<Func<Track, bool>> where = null, 
 | 
							Task<ICollection<Track>> GetTracks(Expression<Func<Track, bool>> where = null, 
 | 
				
			||||||
@ -425,14 +169,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			Expression<Func<Show, object>> sort,
 | 
								Expression<Func<Show, object>> sort,
 | 
				
			||||||
			Pagination limit = default
 | 
								Pagination limit = default
 | 
				
			||||||
		) => GetShows(where, new Sort<Show>(sort), limit);
 | 
							) => 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,
 | 
							Task<ICollection<Track>> GetTracks([Optional] Expression<Func<Track, bool>> where,
 | 
				
			||||||
			Expression<Func<Track, object>> sort,
 | 
								Expression<Func<Track, object>> sort,
 | 
				
			||||||
			Pagination limit = default
 | 
								Pagination limit = default
 | 
				
			||||||
@ -455,7 +191,7 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
		) => GetProviders(where, new Sort<ProviderID>(sort), limit);
 | 
							) => GetProviders(where, new Sort<ProviderID>(sort), limit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// Search
 | 
							// Search
 | 
				
			||||||
		Task<ICollection<Library>> SearchLibraries(string searchQuery);
 | 
							Task<ICollection<Library>> SearchLibraries(string searchQuery);
 | 
				
			||||||
		Task<ICollection<Collection>> SearchCollections(string searchQuery);
 | 
							Task<ICollection<Collection>> SearchCollections(string searchQuery);
 | 
				
			||||||
		Task<ICollection<Show>> SearchShows(string searchQuery);
 | 
							Task<ICollection<Show>> SearchShows(string searchQuery);
 | 
				
			||||||
 | 
				
			|||||||
@ -30,7 +30,7 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		public Sort(Expression<Func<T, object>> key, bool descendant = false)
 | 
							public Sort(Expression<Func<T, object>> key, bool descendant = false)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			Key = key;
 | 
								Key = ExpressionRewrite.Rewrite<Func<T, object>>(key);
 | 
				
			||||||
			Descendant = descendant;
 | 
								Descendant = descendant;
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			if (Key == null || 
 | 
								if (Key == null || 
 | 
				
			||||||
@ -58,6 +58,7 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			Key = property.Type.IsValueType
 | 
								Key = property.Type.IsValueType
 | 
				
			||||||
				? Expression.Lambda<Func<T, object>>(Expression.Convert(property, typeof(object)), param)
 | 
									? Expression.Lambda<Func<T, object>>(Expression.Convert(property, typeof(object)), param)
 | 
				
			||||||
				: Expression.Lambda<Func<T, object>>(property, param);
 | 
									: Expression.Lambda<Func<T, object>>(property, param);
 | 
				
			||||||
 | 
								Key = ExpressionRewrite.Rewrite<Func<T, object>>(Key);
 | 
				
			||||||
					
 | 
										
 | 
				
			||||||
			Descendant = order switch
 | 
								Descendant = order switch
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
@ -109,49 +110,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
	public interface IShowRepository : IRepository<Show>
 | 
						public interface IShowRepository : IRepository<Show>
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		Task AddShowLink(int showID, int? libraryID, int? collectionID);
 | 
							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>
 | 
						public interface ISeasonRepository : IRepository<Season>
 | 
				
			||||||
@ -159,28 +117,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
		Task<Season> Get(int showID, int seasonNumber);
 | 
							Task<Season> Get(int showID, int seasonNumber);
 | 
				
			||||||
		Task<Season> Get(string showSlug, int seasonNumber);
 | 
							Task<Season> Get(string showSlug, int seasonNumber);
 | 
				
			||||||
		Task Delete(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>
 | 
						public interface IEpisodeRepository : IRepository<Episode>
 | 
				
			||||||
@ -191,143 +127,10 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
		Task<Episode> GetAbsolute(int showID, int absoluteNumber);
 | 
							Task<Episode> GetAbsolute(int showID, int absoluteNumber);
 | 
				
			||||||
		Task<Episode> GetAbsolute(string showSlug, int absoluteNumber);
 | 
							Task<Episode> GetAbsolute(string showSlug, int absoluteNumber);
 | 
				
			||||||
		Task Delete(string showSlug, int seasonNumber, int episodeNumber);
 | 
							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>
 | 
						public interface ITrackRepository : IRepository<Track> { }
 | 
				
			||||||
	{
 | 
						public interface ILibraryRepository : IRepository<Library> { }
 | 
				
			||||||
		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 ILibraryItemRepository : IRepository<LibraryItem>
 | 
						public interface ILibraryItemRepository : IRepository<LibraryItem>
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@ -354,77 +157,9 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
		) => GetFromLibrary(librarySlug, where, new Sort<LibraryItem>(sort), limit);
 | 
							) => GetFromLibrary(librarySlug, where, new Sort<LibraryItem>(sort), limit);
 | 
				
			||||||
	}	
 | 
						}	
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	public interface ICollectionRepository : IRepository<Collection>
 | 
						public interface ICollectionRepository : IRepository<Collection> { }
 | 
				
			||||||
	{
 | 
						public interface IGenreRepository : IRepository<Genre> { }
 | 
				
			||||||
		Task<ICollection<Collection>> GetFromShow(int showID,
 | 
						public interface IStudioRepository : IRepository<Studio> { }
 | 
				
			||||||
			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 IPeopleRepository : IRepository<People>
 | 
						public interface IPeopleRepository : IRepository<People>
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@ -468,5 +203,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			Pagination limit = default
 | 
								Pagination limit = default
 | 
				
			||||||
		) => GetFromPeople(showSlug, where, new Sort<ShowRole>(sort), limit);
 | 
							) => GetFromPeople(showSlug, where, new Sort<ShowRole>(sort), limit);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	public interface IProviderRepository : IRepository<ProviderID> {}
 | 
						public interface IProviderRepository : IRepository<ProviderID> {}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -241,18 +241,18 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			return ShowRepository.GetAll(where, sort, limit);
 | 
								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,
 | 
								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,
 | 
								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, 
 | 
							public Task<ICollection<Track>> GetTracks(Expression<Func<Track, bool>> where = null, 
 | 
				
			||||||
@ -290,213 +290,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			return ProviderRepository.GetAll(where, sort, page); 
 | 
								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, 
 | 
							public Task<ICollection<LibraryItem>> GetItemsFromLibrary(int id, 
 | 
				
			||||||
			Expression<Func<LibraryItem, bool>> where = null, 
 | 
								Expression<Func<LibraryItem, bool>> where = null, 
 | 
				
			||||||
			Sort<LibraryItem> sort = default, 
 | 
								Sort<LibraryItem> sort = default, 
 | 
				
			||||||
@ -513,36 +306,20 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			return LibraryItemRepository.GetFromLibrary(librarySlug, where, sort, limit);
 | 
								return LibraryItemRepository.GetFromLibrary(librarySlug, where, sort, limit);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		public Task<ICollection<Show>> GetShowsFromCollection(int id, 
 | 
							public Task<ICollection<PeopleRole>> GetPeopleFromShow(int showID,
 | 
				
			||||||
			Expression<Func<Show, bool>> where = null, 
 | 
								Expression<Func<PeopleRole, bool>> where = null,
 | 
				
			||||||
			Sort<Show> sort = default, 
 | 
								Sort<PeopleRole> sort = default,
 | 
				
			||||||
			Pagination limit = 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, 
 | 
							public Task<ICollection<PeopleRole>> GetPeopleFromShow(string showSlug,
 | 
				
			||||||
			Expression<Func<Show, bool>> where = null, 
 | 
								Expression<Func<PeopleRole, bool>> where = null,
 | 
				
			||||||
			Sort<Show> sort = default, 
 | 
								Sort<PeopleRole> sort = default,
 | 
				
			||||||
			Pagination limit = default)
 | 
								Pagination limit = default)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			return ShowRepository.GetFromCollection(slug, where, sort, limit);
 | 
								return PeopleRepository.GetFromShow(showSlug, 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);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		public Task<ICollection<ShowRole>> GetRolesFromPeople(int id, 
 | 
							public Task<ICollection<ShowRole>> GetRolesFromPeople(int id, 
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										120
									
								
								Kyoo.Common/ExpressionRewrite.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								Kyoo.Common/ExpressionRewrite.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,120 @@
 | 
				
			|||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Linq.Expressions;
 | 
				
			||||||
 | 
					using System.Reflection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Kyoo
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						public class ExpressionRewriteAttribute : Attribute
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							public string Link { get; }
 | 
				
			||||||
 | 
							public string Inner { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							public ExpressionRewriteAttribute(string link, string inner = null)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								Link = link;
 | 
				
			||||||
 | 
								Inner = inner;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public class ExpressionRewrite : ExpressionVisitor
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							private string _inner;
 | 
				
			||||||
 | 
							private readonly List<(string inner, ParameterExpression param, ParameterExpression newParam)> _innerRewrites;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							private ExpressionRewrite()
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								_innerRewrites = new List<(string, ParameterExpression, ParameterExpression)>();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							public static Expression Rewrite(Expression expression)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return new ExpressionRewrite().Visit(expression);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							public static Expression<T> Rewrite<T>(Expression expression) where T : Delegate
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return (Expression<T>)new ExpressionRewrite().Visit(expression);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							protected override Expression VisitMember(MemberExpression node)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								(string inner, _, ParameterExpression p) = _innerRewrites.FirstOrDefault(x => x.param == node.Expression);
 | 
				
			||||||
 | 
								if (inner != null)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									Expression param = p;
 | 
				
			||||||
 | 
									foreach (string accessor in inner.Split('.'))
 | 
				
			||||||
 | 
										param = Expression.Property(param, accessor);
 | 
				
			||||||
 | 
									node = Expression.Property(param, node.Member.Name);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								// Can't use node.Member directly because we want to support attribute override
 | 
				
			||||||
 | 
								MemberInfo member = node.Expression.Type.GetProperty(node.Member.Name) ?? node.Member;
 | 
				
			||||||
 | 
								ExpressionRewriteAttribute attr = member!.GetCustomAttribute<ExpressionRewriteAttribute>();
 | 
				
			||||||
 | 
								if (attr == null)
 | 
				
			||||||
 | 
									return base.VisitMember(node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								Expression property = node.Expression;
 | 
				
			||||||
 | 
								foreach (string child in attr.Link.Split('.'))
 | 
				
			||||||
 | 
									property = Expression.Property(property, child);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								if (property is MemberExpression expr)
 | 
				
			||||||
 | 
									Visit(expr.Expression);
 | 
				
			||||||
 | 
								_inner = attr.Inner;
 | 
				
			||||||
 | 
								return property;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							protected override Expression VisitLambda<T>(Expression<T> node)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								(_, ParameterExpression oldParam, ParameterExpression param) = _innerRewrites
 | 
				
			||||||
 | 
									.FirstOrDefault(x => node.Parameters.Any(y => y == x.param));
 | 
				
			||||||
 | 
								if (param == null)
 | 
				
			||||||
 | 
									return base.VisitLambda(node);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								ParameterExpression[] newParams = node.Parameters.Where(x => x != oldParam).Append(param).ToArray();
 | 
				
			||||||
 | 
								return Expression.Lambda(Visit(node.Body)!, newParams);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							protected override Expression VisitMethodCall(MethodCallExpression node)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								int count = node.Arguments.Count;
 | 
				
			||||||
 | 
								if (node.Object != null)
 | 
				
			||||||
 | 
									count++;
 | 
				
			||||||
 | 
								if (count != 2)
 | 
				
			||||||
 | 
									return base.VisitMethodCall(node);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								Expression instance = node.Object ?? node.Arguments.First();
 | 
				
			||||||
 | 
								Expression argument = node.Object != null
 | 
				
			||||||
 | 
									? node.Arguments.First()
 | 
				
			||||||
 | 
									: node.Arguments[1];
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								Type oldType = instance.Type;
 | 
				
			||||||
 | 
								instance = Visit(instance);
 | 
				
			||||||
 | 
								if (instance!.Type == oldType)
 | 
				
			||||||
 | 
									return base.VisitMethodCall(node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (_inner != null && argument is LambdaExpression lambda)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									// TODO this type handler will usually work with IEnumerable & others but won't work with everything.
 | 
				
			||||||
 | 
									Type type = oldType.GetGenericArguments().First();
 | 
				
			||||||
 | 
									ParameterExpression oldParam = lambda.Parameters.FirstOrDefault(x => x.Type == type);
 | 
				
			||||||
 | 
									if (oldParam != null) 
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										Type newType = instance.Type.GetGenericArguments().First();
 | 
				
			||||||
 | 
										ParameterExpression newParam = Expression.Parameter(newType, oldParam.Name);
 | 
				
			||||||
 | 
										_innerRewrites.Add((_inner, oldParam, newParam));
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								argument = Visit(argument);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								// TODO this method handler may not work for some methods (ex: method taking a Fun<> method won't have good generic arguments)
 | 
				
			||||||
 | 
								MethodInfo method = node.Method.IsGenericMethod
 | 
				
			||||||
 | 
									? node.Method.GetGenericMethodDefinition().MakeGenericMethod(instance.Type.GetGenericArguments())
 | 
				
			||||||
 | 
									: node.Method;
 | 
				
			||||||
 | 
								return node.Object != null
 | 
				
			||||||
 | 
									? Expression.Call(instance, method!, argument) 
 | 
				
			||||||
 | 
									: Expression.Call(null, method!, instance, argument!);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -11,24 +11,28 @@ namespace Kyoo.Models
 | 
				
			|||||||
		[JsonIgnore] public int PeopleID { get; set; }
 | 
							[JsonIgnore] public int PeopleID { get; set; }
 | 
				
			||||||
		[JsonIgnore] public virtual People People { get; set; }
 | 
							[JsonIgnore] public virtual People People { get; set; }
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
							[ExpressionRewrite(nameof(People) + "." + nameof(Models.People.Slug))]
 | 
				
			||||||
		public string Slug
 | 
							public string Slug
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => People.Slug;
 | 
								get => People.Slug;
 | 
				
			||||||
			set => People.Slug = value;
 | 
								set => People.Slug = value;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
							[ExpressionRewrite(nameof(People) + "."+ nameof(Models.People.Name))]
 | 
				
			||||||
		public string Name
 | 
							public string Name
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => People.Name;
 | 
								get => People.Name;
 | 
				
			||||||
			set => People.Name = value;
 | 
								set => People.Name = value;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
							[ExpressionRewrite(nameof(People) + "."+ nameof(Models.People.Poster))]
 | 
				
			||||||
		public string Poster
 | 
							public string Poster
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => People.Poster;
 | 
								get => People.Poster;
 | 
				
			||||||
			set => People.Poster = value;
 | 
								set => People.Poster = value;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
							[ExpressionRewrite(nameof(People) + "."+ nameof(Models.People.ExternalIDs))]
 | 
				
			||||||
		public IEnumerable<MetadataID> ExternalIDs
 | 
							public IEnumerable<MetadataID> ExternalIDs
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => People.ExternalIDs;
 | 
								get => People.ExternalIDs;
 | 
				
			||||||
 | 
				
			|||||||
@ -309,12 +309,14 @@ namespace Kyoo
 | 
				
			|||||||
		public static Expression<T> Convert<T>([CanBeNull] this Expression expr)
 | 
							public static Expression<T> Convert<T>([CanBeNull] this Expression expr)
 | 
				
			||||||
			where T : Delegate
 | 
								where T : Delegate
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			return expr switch
 | 
								Expression<T> e = expr switch
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				null => null,
 | 
									null => null,
 | 
				
			||||||
				LambdaExpression lambda => new ExpressionConverter<T>(lambda).VisitAndConvert(),
 | 
									LambdaExpression lambda => new ExpressionConverter<T>(lambda).VisitAndConvert(),
 | 
				
			||||||
				_ => throw new ArgumentException("Can't convert a non lambda.")
 | 
									_ => throw new ArgumentException("Can't convert a non lambda.")
 | 
				
			||||||
			};
 | 
								};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								return ExpressionRewrite.Rewrite<T>(e);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		private class ExpressionConverter<TTo> : ExpressionVisitor
 | 
							private class ExpressionConverter<TTo> : ExpressionVisitor
 | 
				
			||||||
@ -342,26 +344,17 @@ namespace Kyoo
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			internal Expression<TTo> VisitAndConvert()
 | 
								internal Expression<TTo> VisitAndConvert()
 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				return (Expression<TTo>)RunGenericMethod(
 | 
					 | 
				
			||||||
					this,
 | 
					 | 
				
			||||||
					"VisitLambda",
 | 
					 | 
				
			||||||
					_expression.GetType().GetGenericArguments().First(), 
 | 
					 | 
				
			||||||
					_expression);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			protected override Expression VisitLambda<T>(Expression<T> node)
 | 
					 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Type returnType = _expression.Type.GetGenericArguments().Last();
 | 
									Type returnType = _expression.Type.GetGenericArguments().Last();
 | 
				
			||||||
				Expression body = node.ReturnType == returnType
 | 
									Expression body = _expression.ReturnType == returnType
 | 
				
			||||||
					? Visit(node.Body)
 | 
										? Visit(_expression.Body)
 | 
				
			||||||
					: Expression.Convert(Visit(node.Body)!, returnType);
 | 
										: Expression.Convert(Visit(_expression.Body)!, returnType);
 | 
				
			||||||
				return Expression.Lambda<TTo>(body!, _newParams);
 | 
									return Expression.Lambda<TTo>(body!, _newParams);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			protected override Expression VisitParameter(ParameterExpression node)
 | 
								protected override Expression VisitParameter(ParameterExpression node)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				return _newParams.First(x => x.Name == node.Name);
 | 
									return _newParams.FirstOrDefault(x => x.Name == node.Name) ?? node;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -24,9 +24,14 @@ namespace Kyoo.CommonApi
 | 
				
			|||||||
			Expression<Func<T, bool>> defaultWhere = null)
 | 
								Expression<Func<T, bool>> defaultWhere = null)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if (where == null || where.Count == 0)
 | 
								if (where == null || where.Count == 0)
 | 
				
			||||||
				return defaultWhere;
 | 
								{
 | 
				
			||||||
 | 
									if (defaultWhere == null)
 | 
				
			||||||
 | 
										return null;
 | 
				
			||||||
 | 
									Expression body = ExpressionRewrite.Rewrite(defaultWhere.Body);
 | 
				
			||||||
 | 
									return Expression.Lambda<Func<T, bool>>(body, defaultWhere.Parameters.First());
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			ParameterExpression param = Expression.Parameter(typeof(T));
 | 
								ParameterExpression param = defaultWhere?.Parameters.First() ?? Expression.Parameter(typeof(T));
 | 
				
			||||||
			Expression expression = defaultWhere?.Body;
 | 
								Expression expression = defaultWhere?.Body;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			foreach ((string key, string desired) in where)
 | 
								foreach ((string key, string desired) in where)
 | 
				
			||||||
@ -72,7 +77,8 @@ namespace Kyoo.CommonApi
 | 
				
			|||||||
					expression = condition;
 | 
										expression = condition;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			return Expression.Lambda<Func<T, bool>>(expression!, param);
 | 
								expression = ExpressionRewrite.Rewrite(expression);
 | 
				
			||||||
 | 
								return Expression.Lambda<Func<T, bool>>(expression, param);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		private static Expression ContainsResourceExpression(MemberExpression xProperty, string value)
 | 
							private static Expression ContainsResourceExpression(MemberExpression xProperty, string value)
 | 
				
			||||||
 | 
				
			|||||||
@ -4,9 +4,7 @@ using System.Linq;
 | 
				
			|||||||
using System.Linq.Expressions;
 | 
					using System.Linq.Expressions;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using Kyoo.Models;
 | 
					using Kyoo.Models;
 | 
				
			||||||
using Kyoo.Models.Exceptions;
 | 
					 | 
				
			||||||
using Microsoft.EntityFrameworkCore;
 | 
					using Microsoft.EntityFrameworkCore;
 | 
				
			||||||
using Microsoft.Extensions.DependencyInjection;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Kyoo.Controllers
 | 
					namespace Kyoo.Controllers
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -14,15 +12,11 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		private bool _disposed;
 | 
							private bool _disposed;
 | 
				
			||||||
		private readonly DatabaseContext _database;
 | 
							private readonly DatabaseContext _database;
 | 
				
			||||||
		private readonly Lazy<IShowRepository> _shows;
 | 
					 | 
				
			||||||
		private readonly Lazy<ILibraryRepository> _libraries;
 | 
					 | 
				
			||||||
		protected override Expression<Func<CollectionDE, object>> DefaultSort => x => x.Name;
 | 
							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;
 | 
								_database = database;
 | 
				
			||||||
			_shows = new Lazy<IShowRepository>(services.GetRequiredService<IShowRepository>);
 | 
					 | 
				
			||||||
			_libraries = new Lazy<ILibraryRepository>(services.GetRequiredService<ILibraryRepository>);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public override void Dispose()
 | 
							public override void Dispose()
 | 
				
			||||||
@ -31,10 +25,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
				return;
 | 
									return;
 | 
				
			||||||
			_disposed = true;
 | 
								_disposed = true;
 | 
				
			||||||
			_database.Dispose();
 | 
								_database.Dispose();
 | 
				
			||||||
			if (_shows.IsValueCreated)
 | 
					 | 
				
			||||||
				_shows.Value.Dispose();
 | 
					 | 
				
			||||||
			if (_libraries.IsValueCreated)
 | 
					 | 
				
			||||||
				_libraries.Value.Dispose();
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public override async ValueTask DisposeAsync()
 | 
							public override async ValueTask DisposeAsync()
 | 
				
			||||||
@ -43,10 +33,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
				return;
 | 
									return;
 | 
				
			||||||
			_disposed = true;
 | 
								_disposed = true;
 | 
				
			||||||
			await _database.DisposeAsync();
 | 
								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)
 | 
							public override async Task<ICollection<Collection>> Search(string query)
 | 
				
			||||||
@ -79,71 +65,5 @@ 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 => (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;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -15,21 +15,13 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
		private bool _disposed;
 | 
							private bool _disposed;
 | 
				
			||||||
		private readonly DatabaseContext _database;
 | 
							private readonly DatabaseContext _database;
 | 
				
			||||||
		private readonly IProviderRepository _providers;
 | 
							private readonly IProviderRepository _providers;
 | 
				
			||||||
		private readonly IShowRepository _shows;
 | 
					 | 
				
			||||||
		private readonly ISeasonRepository _seasons;
 | 
					 | 
				
			||||||
		protected override Expression<Func<Episode, object>> DefaultSort => x => x.EpisodeNumber;
 | 
							protected override Expression<Func<Episode, object>> DefaultSort => x => x.EpisodeNumber;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public EpisodeRepository(DatabaseContext database,
 | 
							public EpisodeRepository(DatabaseContext database, IProviderRepository providers) : base(database)
 | 
				
			||||||
			IProviderRepository providers,
 | 
					 | 
				
			||||||
			IShowRepository shows,
 | 
					 | 
				
			||||||
			ISeasonRepository seasons)
 | 
					 | 
				
			||||||
			: base(database)
 | 
					 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			_database = database;
 | 
								_database = database;
 | 
				
			||||||
			_providers = providers;
 | 
								_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)
 | 
							public async Task Delete(string showSlug, int seasonNumber, int episodeNumber)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			Episode obj = await Get(showSlug, seasonNumber, episodeNumber);
 | 
								Episode obj = await Get(showSlug, seasonNumber, episodeNumber);
 | 
				
			||||||
 | 
				
			|||||||
@ -14,14 +14,12 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		private bool _disposed;
 | 
							private bool _disposed;
 | 
				
			||||||
		private readonly DatabaseContext _database;
 | 
							private readonly DatabaseContext _database;
 | 
				
			||||||
		private readonly Lazy<IShowRepository> _shows;
 | 
					 | 
				
			||||||
		protected override Expression<Func<GenreDE, object>> DefaultSort => x => x.Slug;
 | 
							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;
 | 
								_database = database;
 | 
				
			||||||
			_shows = new Lazy<IShowRepository>(services.GetRequiredService<IShowRepository>);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public override void Dispose()
 | 
							public override void Dispose()
 | 
				
			||||||
@ -30,8 +28,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
				return;
 | 
									return;
 | 
				
			||||||
			_disposed = true;
 | 
								_disposed = true;
 | 
				
			||||||
			_database.Dispose();
 | 
								_database.Dispose();
 | 
				
			||||||
			if (_shows.IsValueCreated)
 | 
					 | 
				
			||||||
				_shows.Value.Dispose();
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public override async ValueTask DisposeAsync()
 | 
							public override async ValueTask DisposeAsync()
 | 
				
			||||||
@ -40,8 +36,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
				return;
 | 
									return;
 | 
				
			||||||
			_disposed = true;
 | 
								_disposed = true;
 | 
				
			||||||
			await _database.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)
 | 
				
			||||||
@ -71,36 +65,5 @@ 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<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;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -15,16 +15,14 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
		private bool _disposed;
 | 
							private bool _disposed;
 | 
				
			||||||
		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<LibraryDE, object>> DefaultSort => x => x.ID;
 | 
							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)
 | 
								: 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()
 | 
				
			||||||
@ -34,8 +32,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			_disposed = true;
 | 
								_disposed = true;
 | 
				
			||||||
			_database.Dispose();
 | 
								_database.Dispose();
 | 
				
			||||||
			_providers.Dispose();
 | 
								_providers.Dispose();
 | 
				
			||||||
			if (_shows.IsValueCreated)
 | 
					 | 
				
			||||||
				_shows.Value.Dispose();
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public override async ValueTask DisposeAsync()
 | 
							public override async ValueTask DisposeAsync()
 | 
				
			||||||
@ -45,8 +41,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			_disposed = true;
 | 
								_disposed = true;
 | 
				
			||||||
			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)
 | 
				
			||||||
@ -99,69 +93,5 @@ 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 => (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;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -98,16 +98,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			Sort<PeopleRole> sort = default, 
 | 
								Sort<PeopleRole> sort = default, 
 | 
				
			||||||
			Pagination limit = default)
 | 
								Pagination limit = default)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if (sort.Key?.Body is MemberExpression member)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				sort.Key = member.Member.Name switch
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					"Name" => x => x.People.Name,
 | 
					 | 
				
			||||||
					"Slug" => x => x.People.Slug,
 | 
					 | 
				
			||||||
					_ => sort.Key
 | 
					 | 
				
			||||||
				};
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			ICollection<PeopleRole> people = await ApplyFilters(_database.PeopleRoles.Where(x => x.ShowID == showID),
 | 
								ICollection<PeopleRole> people = await ApplyFilters(_database.PeopleRoles.Where(x => x.ShowID == showID),
 | 
				
			||||||
				id => _database.PeopleRoles.FirstOrDefaultAsync(x => x.ID == id),
 | 
									id => _database.PeopleRoles.FirstOrDefaultAsync(x => x.ID == id),
 | 
				
			||||||
				x => x.People.Name,
 | 
									x => x.People.Name,
 | 
				
			||||||
@ -124,16 +114,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			Sort<PeopleRole> sort = default, 
 | 
								Sort<PeopleRole> sort = default, 
 | 
				
			||||||
			Pagination limit = default)
 | 
								Pagination limit = default)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if (sort.Key?.Body is MemberExpression member)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				sort.Key = member.Member.Name switch
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					"Name" => x => x.People.Name,
 | 
					 | 
				
			||||||
					"Slug" => x => x.People.Slug,
 | 
					 | 
				
			||||||
					_ => sort.Key
 | 
					 | 
				
			||||||
				};
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			ICollection<PeopleRole> people = await ApplyFilters(_database.PeopleRoles.Where(x => x.Show.Slug == showSlug),
 | 
								ICollection<PeopleRole> people = await ApplyFilters(_database.PeopleRoles.Where(x => x.Show.Slug == showSlug),
 | 
				
			||||||
				id => _database.PeopleRoles.FirstOrDefaultAsync(x => x.ID == id),
 | 
									id => _database.PeopleRoles.FirstOrDefaultAsync(x => x.ID == id),
 | 
				
			||||||
				x => x.People.Name,
 | 
									x => x.People.Name,
 | 
				
			||||||
 | 
				
			|||||||
@ -17,20 +17,17 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
		private readonly DatabaseContext _database;
 | 
							private readonly DatabaseContext _database;
 | 
				
			||||||
		private readonly IProviderRepository _providers;
 | 
							private readonly IProviderRepository _providers;
 | 
				
			||||||
		private readonly Lazy<IEpisodeRepository> _episodes;
 | 
							private readonly Lazy<IEpisodeRepository> _episodes;
 | 
				
			||||||
		private readonly IShowRepository _shows;
 | 
					 | 
				
			||||||
		protected override Expression<Func<Season, object>> DefaultSort => x => x.SeasonNumber;
 | 
							protected override Expression<Func<Season, object>> DefaultSort => x => x.SeasonNumber;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public SeasonRepository(DatabaseContext database, 
 | 
							public SeasonRepository(DatabaseContext database, 
 | 
				
			||||||
			IProviderRepository providers,
 | 
								IProviderRepository providers,
 | 
				
			||||||
			IShowRepository shows,
 | 
					 | 
				
			||||||
			IServiceProvider services)
 | 
								IServiceProvider services)
 | 
				
			||||||
			: base(database)
 | 
								: base(database)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			_database = database;
 | 
								_database = database;
 | 
				
			||||||
			_providers = providers;
 | 
								_providers = providers;
 | 
				
			||||||
			_episodes = new Lazy<IEpisodeRepository>(services.GetRequiredService<IEpisodeRepository>);
 | 
								_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)
 | 
							public async Task Delete(string showSlug, int seasonNumber)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			Season obj = await Get(showSlug, seasonNumber);
 | 
								Season obj = await Get(showSlug, seasonNumber);
 | 
				
			||||||
@ -161,10 +130,5 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			if (obj.Episodes != null)
 | 
								if (obj.Episodes != null)
 | 
				
			||||||
				await _episodes.Value.DeleteRange(obj.Episodes);
 | 
									await _episodes.Value.DeleteRange(obj.Episodes);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					 | 
				
			||||||
		public Task<Season> GetFromEpisode(int episodeID)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			return _database.Seasons.FirstOrDefaultAsync(x => x.Episodes.Any(y => y.ID == episodeID));
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -4,7 +4,6 @@ using System.Linq;
 | 
				
			|||||||
using System.Linq.Expressions;
 | 
					using System.Linq.Expressions;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using Kyoo.Models;
 | 
					using Kyoo.Models;
 | 
				
			||||||
using Kyoo.Models.Exceptions;
 | 
					 | 
				
			||||||
using Microsoft.EntityFrameworkCore;
 | 
					using Microsoft.EntityFrameworkCore;
 | 
				
			||||||
using Microsoft.Extensions.DependencyInjection;
 | 
					using Microsoft.Extensions.DependencyInjection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -20,8 +19,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
		private readonly IProviderRepository _providers;
 | 
							private readonly IProviderRepository _providers;
 | 
				
			||||||
		private readonly Lazy<ISeasonRepository> _seasons;
 | 
							private readonly Lazy<ISeasonRepository> _seasons;
 | 
				
			||||||
		private readonly Lazy<IEpisodeRepository> _episodes;
 | 
							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;
 | 
							protected override Expression<Func<ShowDE, object>> DefaultSort => x => x.Title;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public ShowRepository(DatabaseContext database,
 | 
							public ShowRepository(DatabaseContext database,
 | 
				
			||||||
@ -39,8 +36,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			_providers = providers;
 | 
								_providers = providers;
 | 
				
			||||||
			_seasons = new Lazy<ISeasonRepository>(services.GetRequiredService<ISeasonRepository>);
 | 
								_seasons = new Lazy<ISeasonRepository>(services.GetRequiredService<ISeasonRepository>);
 | 
				
			||||||
			_episodes = new Lazy<IEpisodeRepository>(services.GetRequiredService<IEpisodeRepository>);
 | 
								_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()
 | 
							public override void Dispose()
 | 
				
			||||||
@ -57,10 +52,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
				_seasons.Value.Dispose();
 | 
									_seasons.Value.Dispose();
 | 
				
			||||||
			if (_episodes.IsValueCreated)
 | 
								if (_episodes.IsValueCreated)
 | 
				
			||||||
				_episodes.Value.Dispose();
 | 
									_episodes.Value.Dispose();
 | 
				
			||||||
			if (_libraries.IsValueCreated)
 | 
					 | 
				
			||||||
				_libraries.Value.Dispose();
 | 
					 | 
				
			||||||
			if (_collections.IsValueCreated)
 | 
					 | 
				
			||||||
				_collections.Value.Dispose();
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public override async ValueTask DisposeAsync()
 | 
							public override async ValueTask DisposeAsync()
 | 
				
			||||||
@ -77,10 +68,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
				await _seasons.Value.DisposeAsync();
 | 
									await _seasons.Value.DisposeAsync();
 | 
				
			||||||
			if (_episodes.IsValueCreated)
 | 
								if (_episodes.IsValueCreated)
 | 
				
			||||||
				await _episodes.Value.DisposeAsync();
 | 
									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)
 | 
							public override async Task<ICollection<Show>> Search(string query)
 | 
				
			||||||
@ -186,83 +173,5 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			if (obj.Episodes != null) 
 | 
								if (obj.Episodes != null) 
 | 
				
			||||||
				await _episodes.Value.DeleteRange(obj.Episodes);
 | 
									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>();
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -4,7 +4,6 @@ using System.Linq;
 | 
				
			|||||||
using System.Linq.Expressions;
 | 
					using System.Linq.Expressions;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using Kyoo.Models;
 | 
					using Kyoo.Models;
 | 
				
			||||||
using Kyoo.Models.Exceptions;
 | 
					 | 
				
			||||||
using Microsoft.EntityFrameworkCore;
 | 
					using Microsoft.EntityFrameworkCore;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Kyoo.Controllers
 | 
					namespace Kyoo.Controllers
 | 
				
			||||||
@ -48,27 +47,5 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
				show.StudioID = null;
 | 
									show.StudioID = null;
 | 
				
			||||||
			await _database.SaveChangesAsync();
 | 
								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;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1,13 +1,10 @@
 | 
				
			|||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Linq.Expressions;
 | 
					using System.Linq.Expressions;
 | 
				
			||||||
using System.Text.RegularExpressions;
 | 
					using System.Text.RegularExpressions;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using Kyoo.Models;
 | 
					using Kyoo.Models;
 | 
				
			||||||
using Kyoo.Models.Exceptions;
 | 
					 | 
				
			||||||
using Microsoft.EntityFrameworkCore;
 | 
					using Microsoft.EntityFrameworkCore;
 | 
				
			||||||
using Microsoft.Extensions.DependencyInjection;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Kyoo.Controllers
 | 
					namespace Kyoo.Controllers
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -15,14 +12,12 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		private bool _disposed;
 | 
							private bool _disposed;
 | 
				
			||||||
		private readonly DatabaseContext _database;
 | 
							private readonly DatabaseContext _database;
 | 
				
			||||||
		private readonly Lazy<IEpisodeRepository> _episodes;
 | 
					 | 
				
			||||||
		protected override Expression<Func<Track, object>> DefaultSort => x => x.ID;
 | 
							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;
 | 
								_database = database;
 | 
				
			||||||
			_episodes = new Lazy<IEpisodeRepository>(services.GetRequiredService<IEpisodeRepository>);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public override void Dispose()
 | 
							public override void Dispose()
 | 
				
			||||||
@ -31,8 +26,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
				return;
 | 
									return;
 | 
				
			||||||
			_disposed = true;
 | 
								_disposed = true;
 | 
				
			||||||
			_database.Dispose();
 | 
								_database.Dispose();
 | 
				
			||||||
			if (_episodes.IsValueCreated)
 | 
					 | 
				
			||||||
				_episodes.Value.Dispose();
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public override async ValueTask DisposeAsync()
 | 
							public override async ValueTask DisposeAsync()
 | 
				
			||||||
@ -41,8 +34,6 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
				return;
 | 
									return;
 | 
				
			||||||
			_disposed = true;
 | 
								_disposed = true;
 | 
				
			||||||
			await _database.DisposeAsync();
 | 
								await _database.DisposeAsync();
 | 
				
			||||||
			if (_episodes.IsValueCreated)
 | 
					 | 
				
			||||||
				await _episodes.Value.DisposeAsync();
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public override Task<Track> Get(string slug)
 | 
							public override Task<Track> Get(string slug)
 | 
				
			||||||
@ -97,55 +88,5 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
			_database.Entry(obj).State = EntityState.Deleted;
 | 
								_database.Entry(obj).State = EntityState.Deleted;
 | 
				
			||||||
			await _database.SaveChangesAsync();
 | 
								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;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -8,6 +8,7 @@ namespace Kyoo.Models
 | 
				
			|||||||
	public class CollectionDE : Collection
 | 
						public class CollectionDE : Collection
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		[JsonIgnore] [NotMergable] public virtual IEnumerable<CollectionLink> Links { get; set; }
 | 
							[JsonIgnore] [NotMergable] public virtual IEnumerable<CollectionLink> Links { get; set; }
 | 
				
			||||||
 | 
							[ExpressionRewrite(nameof(Links), nameof(CollectionLink.Show))]
 | 
				
			||||||
		public override IEnumerable<Show> Shows
 | 
							public override IEnumerable<Show> Shows
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => Links?.Select(x => x.Show);
 | 
								get => Links?.Select(x => x.Show);
 | 
				
			||||||
@ -15,7 +16,9 @@ namespace Kyoo.Models
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		[JsonIgnore] [NotMergable] public virtual IEnumerable<LibraryLink> LibraryLinks { get; set; }
 | 
							[JsonIgnore] [NotMergable] public virtual IEnumerable<LibraryLink> LibraryLinks { get; set; }
 | 
				
			||||||
		/*[ExpressionRewrite(x => x.LibraryLinks, y => y.Genre)]*/ public override IEnumerable<Library> Libraries
 | 
							
 | 
				
			||||||
 | 
							[ExpressionRewrite(nameof(LibraryLinks), nameof(GenreLink.Genre))]
 | 
				
			||||||
 | 
							public override IEnumerable<Library> Libraries
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => LibraryLinks?.Select(x => x.Library);
 | 
								get => LibraryLinks?.Select(x => x.Library);
 | 
				
			||||||
			set => LibraryLinks = value?.Select(x => new LibraryLink(x, this));
 | 
								set => LibraryLinks = value?.Select(x => new LibraryLink(x, this));
 | 
				
			||||||
 | 
				
			|||||||
@ -9,6 +9,7 @@ namespace Kyoo.Models
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		[JsonIgnore] [NotMergable] public virtual IEnumerable<GenreLink> Links { get; set; }
 | 
							[JsonIgnore] [NotMergable] public virtual IEnumerable<GenreLink> Links { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							[ExpressionRewrite(nameof(Links), nameof(GenreLink.Genre))]
 | 
				
			||||||
		[JsonIgnore] [NotMergable] public override IEnumerable<Show> Shows
 | 
							[JsonIgnore] [NotMergable] public override IEnumerable<Show> Shows
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => Links?.Select(x => x.Show);
 | 
								get => Links?.Select(x => x.Show);
 | 
				
			||||||
 | 
				
			|||||||
@ -8,6 +8,7 @@ namespace Kyoo.Models
 | 
				
			|||||||
	public class LibraryDE : Library
 | 
						public class LibraryDE : Library
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		[JsonIgnore] [NotMergable] public virtual IEnumerable<ProviderLink> ProviderLinks { get; set; }
 | 
							[JsonIgnore] [NotMergable] public virtual IEnumerable<ProviderLink> ProviderLinks { get; set; }
 | 
				
			||||||
 | 
							[ExpressionRewrite(nameof(ProviderLinks), nameof(ProviderLink.Provider))]
 | 
				
			||||||
		public override IEnumerable<ProviderID> Providers
 | 
							public override IEnumerable<ProviderID> Providers
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => ProviderLinks?.Select(x => x.Provider);
 | 
								get => ProviderLinks?.Select(x => x.Provider);
 | 
				
			||||||
@ -15,6 +16,7 @@ namespace Kyoo.Models
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		[JsonIgnore] [NotMergable] public virtual IEnumerable<LibraryLink> Links { get; set; }
 | 
							[JsonIgnore] [NotMergable] public virtual IEnumerable<LibraryLink> Links { get; set; }
 | 
				
			||||||
 | 
							[ExpressionRewrite(nameof(Links), nameof(LibraryLink.Show))]
 | 
				
			||||||
		public override IEnumerable<Show> Shows
 | 
							public override IEnumerable<Show> Shows
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => Links?.Where(x => x.Show != null).Select(x => x.Show);
 | 
								get => Links?.Where(x => x.Show != null).Select(x => x.Show);
 | 
				
			||||||
@ -22,6 +24,7 @@ namespace Kyoo.Models
 | 
				
			|||||||
				value?.Select(x => new LibraryLink(this, x)), 
 | 
									value?.Select(x => new LibraryLink(this, x)), 
 | 
				
			||||||
				Links?.Where(x => x.Show == null));
 | 
									Links?.Where(x => x.Show == null));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							[ExpressionRewrite(nameof(Links), nameof(LibraryLink.Collection))]
 | 
				
			||||||
		public override IEnumerable<Collection> Collections
 | 
							public override IEnumerable<Collection> Collections
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => Links?.Where(x => x.Collection != null).Select(x => x.Collection);
 | 
								get => Links?.Where(x => x.Collection != null).Select(x => x.Collection);
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,7 @@ namespace Kyoo.Models
 | 
				
			|||||||
	public class ShowDE : Show
 | 
						public class ShowDE : Show
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		[JsonIgnore] [NotMergable] public virtual IEnumerable<GenreLink> GenreLinks { get; set; }
 | 
							[JsonIgnore] [NotMergable] public virtual IEnumerable<GenreLink> GenreLinks { get; set; }
 | 
				
			||||||
 | 
							[ExpressionRewrite(nameof(GenreLinks), nameof(GenreLink.Genre))]
 | 
				
			||||||
		public override IEnumerable<Genre> Genres
 | 
							public override IEnumerable<Genre> Genres
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => GenreLinks?.Select(x => x.Genre);
 | 
								get => GenreLinks?.Select(x => x.Genre);
 | 
				
			||||||
@ -18,6 +19,7 @@ namespace Kyoo.Models
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		[JsonIgnore] [NotMergable] public virtual IEnumerable<LibraryLink> LibraryLinks { get; set; }
 | 
							[JsonIgnore] [NotMergable] public virtual IEnumerable<LibraryLink> LibraryLinks { get; set; }
 | 
				
			||||||
 | 
							[ExpressionRewrite(nameof(LibraryLinks), nameof(LibraryLink.Library))]
 | 
				
			||||||
		public override IEnumerable<Library> Libraries
 | 
							public override IEnumerable<Library> Libraries
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => LibraryLinks?.Select(x => x.Library);
 | 
								get => LibraryLinks?.Select(x => x.Library);
 | 
				
			||||||
@ -25,7 +27,7 @@ namespace Kyoo.Models
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		[JsonIgnore] [NotMergable] public virtual IEnumerable<CollectionLink> CollectionLinks { get; set; }
 | 
							[JsonIgnore] [NotMergable] public virtual IEnumerable<CollectionLink> CollectionLinks { get; set; }
 | 
				
			||||||
		
 | 
							[ExpressionRewrite(nameof(CollectionLinks), nameof(CollectionLink.Collection))]
 | 
				
			||||||
		public override IEnumerable<Collection> Collections
 | 
							public override IEnumerable<Collection> Collections
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			get => CollectionLinks?.Select(x => x.Collection);
 | 
								get => CollectionLinks?.Select(x => x.Collection);
 | 
				
			||||||
 | 
				
			|||||||
@ -63,7 +63,7 @@ namespace Kyoo.Controllers
 | 
				
			|||||||
				if (!Directory.Exists(show.Path))
 | 
									if (!Directory.Exists(show.Path))
 | 
				
			||||||
					await libraryManager.DeleteShow(show);
 | 
										await libraryManager.DeleteShow(show);
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			ICollection<Episode> episodes = await libraryManager.GetEpisodesFromShow();
 | 
								ICollection<Episode> episodes = await libraryManager.GetEpisodes();
 | 
				
			||||||
			ICollection<Library> libraries = argument == null 
 | 
								ICollection<Library> libraries = argument == null 
 | 
				
			||||||
				? await libraryManager.GetLibraries()
 | 
									? await libraryManager.GetLibraries()
 | 
				
			||||||
				: new [] { await libraryManager.GetLibrary(argument)};
 | 
									: new [] { await libraryManager.GetLibrary(argument)};
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,6 @@
 | 
				
			|||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
using Kyoo.Controllers;
 | 
					using Kyoo.Controllers;
 | 
				
			||||||
using Kyoo.Models;
 | 
					using Kyoo.Models;
 | 
				
			||||||
using Microsoft.AspNetCore.Mvc;
 | 
					using Microsoft.AspNetCore.Mvc;
 | 
				
			||||||
@ -39,8 +40,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Show> ressources = await _libraryManager.GetShowsFromCollection(id,
 | 
									ICollection<Show> ressources = await _libraryManager.GetShows(
 | 
				
			||||||
					ApiHelper.ParseWhere<Show>(where),
 | 
										ApiHelper.ParseWhere<Show>(where, x => x.Collections.Any(y => y.ID == id)),
 | 
				
			||||||
					new Sort<Show>(sortBy),
 | 
										new Sort<Show>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -71,8 +72,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Show> ressources = await _libraryManager.GetShowsFromCollection(slug,
 | 
									ICollection<Show> ressources = await _libraryManager.GetShows(
 | 
				
			||||||
					ApiHelper.ParseWhere<Show>(where),
 | 
										ApiHelper.ParseWhere<Show>(where, x => x.Collections.Any(y => y.Slug == slug)),
 | 
				
			||||||
					new Sort<Show>(sortBy),
 | 
										new Sort<Show>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -103,8 +104,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Library> ressources = await _libraryManager.GetLibrariesFromCollection(id,
 | 
									ICollection<Library> ressources = await _libraryManager.GetLibraries(
 | 
				
			||||||
					ApiHelper.ParseWhere<Library>(where),
 | 
										ApiHelper.ParseWhere<Library>(where, x => x.Collections.Any(y => y.ID == id)),
 | 
				
			||||||
					new Sort<Library>(sortBy),
 | 
										new Sort<Library>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -135,8 +136,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Library> ressources = await _libraryManager.GetLibrariesFromCollection(slug,
 | 
									ICollection<Library> ressources = await _libraryManager.GetLibraries(
 | 
				
			||||||
					ApiHelper.ParseWhere<Library>(where),
 | 
										ApiHelper.ParseWhere<Library>(where, x => x.Collections.Any(y => y.Slug == slug)),
 | 
				
			||||||
					new Sort<Library>(sortBy),
 | 
										new Sort<Library>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -2,6 +2,7 @@
 | 
				
			|||||||
using Kyoo.Models;
 | 
					using Kyoo.Models;
 | 
				
			||||||
using Microsoft.AspNetCore.Mvc;
 | 
					using Microsoft.AspNetCore.Mvc;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using Kyoo.CommonApi;
 | 
					using Kyoo.CommonApi;
 | 
				
			||||||
using Kyoo.Controllers;
 | 
					using Kyoo.Controllers;
 | 
				
			||||||
@ -28,7 +29,7 @@ namespace Kyoo.Api
 | 
				
			|||||||
		[Authorize(Policy = "Read")]
 | 
							[Authorize(Policy = "Read")]
 | 
				
			||||||
		public async Task<ActionResult<Show>> GetShow(int episodeID)
 | 
							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")]
 | 
							[HttpGet("{showSlug}-s{seasonNumber:int}e{episodeNumber:int}/show")]
 | 
				
			||||||
@ -49,7 +50,7 @@ namespace Kyoo.Api
 | 
				
			|||||||
		[Authorize(Policy = "Read")]
 | 
							[Authorize(Policy = "Read")]
 | 
				
			||||||
		public async Task<ActionResult<Season>> GetSeason(int episodeID)
 | 
							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")]
 | 
							[HttpGet("{showSlug}-s{seasonNumber:int}e{episodeNumber:int}/season")]
 | 
				
			||||||
@ -81,8 +82,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Track> ressources = await _libraryManager.GetTracksFromEpisode(episodeID,
 | 
									ICollection<Track> ressources = await _libraryManager.GetTracks(
 | 
				
			||||||
					ApiHelper.ParseWhere<Track>(where),
 | 
										ApiHelper.ParseWhere<Track>(where, x => x.Episode.ID == episodeID),
 | 
				
			||||||
					new Sort<Track>(sortBy),
 | 
										new Sort<Track>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -115,10 +116,10 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Track> ressources = await _libraryManager.GetTracksFromEpisode(showID,
 | 
									ICollection<Track> ressources = await _libraryManager.GetTracks(
 | 
				
			||||||
					seasonNumber,
 | 
										ApiHelper.ParseWhere<Track>(where, x => x.Episode.ShowID == showID 
 | 
				
			||||||
					episodeNumber,
 | 
										                                        && x.Episode.SeasonNumber == seasonNumber
 | 
				
			||||||
					ApiHelper.ParseWhere<Track>(where),
 | 
										                                        && x.Episode.EpisodeNumber == episodeNumber),
 | 
				
			||||||
					new Sort<Track>(sortBy),
 | 
										new Sort<Track>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -151,10 +152,9 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Track> ressources = await _libraryManager.GetTracksFromEpisode(showSlug,
 | 
									ICollection<Track> ressources = await _libraryManager.GetTracks(ApiHelper.ParseWhere<Track>(where, x => x.Episode.Show.Slug == showSlug 
 | 
				
			||||||
					seasonNumber,
 | 
											&& x.Episode.SeasonNumber == seasonNumber
 | 
				
			||||||
					episodeNumber,
 | 
											&& x.Episode.EpisodeNumber == episodeNumber),
 | 
				
			||||||
					ApiHelper.ParseWhere<Track>(where),
 | 
					 | 
				
			||||||
					new Sort<Track>(sortBy),
 | 
										new Sort<Track>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,6 @@
 | 
				
			|||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
using Kyoo.Controllers;
 | 
					using Kyoo.Controllers;
 | 
				
			||||||
using Kyoo.Models;
 | 
					using Kyoo.Models;
 | 
				
			||||||
using Microsoft.AspNetCore.Mvc;
 | 
					using Microsoft.AspNetCore.Mvc;
 | 
				
			||||||
@ -50,8 +51,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Show> ressources = await _libraryManager.GetShowsFromLibrary(id,
 | 
									ICollection<Show> ressources = await _libraryManager.GetShows(
 | 
				
			||||||
					ApiHelper.ParseWhere<Show>(where),
 | 
										ApiHelper.ParseWhere<Show>(where, x => x.Libraries.Any(y => y.ID == id)),
 | 
				
			||||||
					new Sort<Show>(sortBy),
 | 
										new Sort<Show>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -82,8 +83,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Show> ressources = await _libraryManager.GetShowsFromLibrary(slug,
 | 
									ICollection<Show> ressources = await _libraryManager.GetShows(
 | 
				
			||||||
					ApiHelper.ParseWhere<Show>(where),
 | 
										ApiHelper.ParseWhere<Show>(where, x => x.Libraries.Any(y => y.Slug == slug)),
 | 
				
			||||||
					new Sort<Show>(sortBy),
 | 
										new Sort<Show>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -114,8 +115,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Collection> ressources = await _libraryManager.GetCollectionsFromLibrary(id,
 | 
									ICollection<Collection> ressources = await _libraryManager.GetCollections(
 | 
				
			||||||
					ApiHelper.ParseWhere<Collection>(where),
 | 
										ApiHelper.ParseWhere<Collection>(where, x => x.Libraries.Any(y => y.ID == id)),
 | 
				
			||||||
					new Sort<Collection>(sortBy),
 | 
										new Sort<Collection>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -146,8 +147,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Collection> ressources = await _libraryManager.GetCollectionsFromLibrary(slug,
 | 
									ICollection<Collection> ressources = await _libraryManager.GetCollections(
 | 
				
			||||||
					ApiHelper.ParseWhere<Collection>(where),
 | 
										ApiHelper.ParseWhere<Collection>(where, x => x.Libraries.Any(y => y.Slug == slug)),
 | 
				
			||||||
					new Sort<Collection>(sortBy),
 | 
										new Sort<Collection>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,7 @@ using Kyoo.Models;
 | 
				
			|||||||
using Kyoo.Models.Exceptions;
 | 
					using Kyoo.Models.Exceptions;
 | 
				
			||||||
using Microsoft.AspNetCore.Authorization;
 | 
					using Microsoft.AspNetCore.Authorization;
 | 
				
			||||||
using Microsoft.AspNetCore.Mvc;
 | 
					using Microsoft.AspNetCore.Mvc;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
using Microsoft.Extensions.Configuration;
 | 
					using Microsoft.Extensions.Configuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Kyoo.Api
 | 
					namespace Kyoo.Api
 | 
				
			||||||
@ -39,8 +40,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Episode> ressources = await _libraryManager.GetEpisodesFromSeason(seasonID,
 | 
									ICollection<Episode> ressources = await _libraryManager.GetEpisodes(
 | 
				
			||||||
					ApiHelper.ParseWhere<Episode>(where),
 | 
										ApiHelper.ParseWhere<Episode>(where, x => x.SeasonID == seasonID),
 | 
				
			||||||
					new Sort<Episode>(sortBy),
 | 
										new Sort<Episode>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -72,9 +73,9 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Episode> ressources = await _libraryManager.GetEpisodesFromSeason(showSlug,
 | 
									ICollection<Episode> ressources = await _libraryManager.GetEpisodes(
 | 
				
			||||||
					seasonNumber,
 | 
										ApiHelper.ParseWhere<Episode>(where, x => x.Show.Slug == showSlug 
 | 
				
			||||||
					ApiHelper.ParseWhere<Episode>(where),
 | 
										                                          && x.SeasonNumber == seasonNumber),
 | 
				
			||||||
					new Sort<Episode>(sortBy),
 | 
										new Sort<Episode>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -106,9 +107,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Episode> ressources = await _libraryManager.GetEpisodesFromSeason(showID,
 | 
									ICollection<Episode> ressources = await _libraryManager.GetEpisodes(
 | 
				
			||||||
					seasonNumber,
 | 
										ApiHelper.ParseWhere<Episode>(where, x => x.ShowID == showID && x.SeasonNumber == seasonNumber),
 | 
				
			||||||
					ApiHelper.ParseWhere<Episode>(where),
 | 
					 | 
				
			||||||
					new Sort<Episode>(sortBy),
 | 
										new Sort<Episode>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -128,7 +128,7 @@ namespace Kyoo.Api
 | 
				
			|||||||
		[Authorize(Policy = "Read")]
 | 
							[Authorize(Policy = "Read")]
 | 
				
			||||||
		public async Task<ActionResult<Show>> GetShow(int seasonID)
 | 
							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")]
 | 
							[HttpGet("{showSlug}-s{seasonNumber:int}/show")]
 | 
				
			||||||
 | 
				
			|||||||
@ -2,6 +2,7 @@
 | 
				
			|||||||
using Kyoo.Models;
 | 
					using Kyoo.Models;
 | 
				
			||||||
using Microsoft.AspNetCore.Mvc;
 | 
					using Microsoft.AspNetCore.Mvc;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using Kyoo.CommonApi;
 | 
					using Kyoo.CommonApi;
 | 
				
			||||||
using Kyoo.Controllers;
 | 
					using Kyoo.Controllers;
 | 
				
			||||||
@ -39,8 +40,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Season> ressources = await _libraryManager.GetSeasonsFromShow(showID,
 | 
									ICollection<Season> ressources = await _libraryManager.GetSeasons(
 | 
				
			||||||
					ApiHelper.ParseWhere<Season>(where),
 | 
										ApiHelper.ParseWhere<Season>(where, x => x.ShowID == showID),
 | 
				
			||||||
					new Sort<Season>(sortBy),
 | 
										new Sort<Season>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -71,8 +72,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Season> ressources = await _libraryManager.GetSeasonsFromShow(slug,
 | 
									ICollection<Season> ressources = await _libraryManager.GetSeasons(
 | 
				
			||||||
					ApiHelper.ParseWhere<Season>(where),
 | 
										ApiHelper.ParseWhere<Season>(where, x => x.Show.Slug == slug),
 | 
				
			||||||
					new Sort<Season>(sortBy),
 | 
										new Sort<Season>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -103,8 +104,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Episode> ressources = await _libraryManager.GetEpisodesFromShow(showID,
 | 
									ICollection<Episode> ressources = await _libraryManager.GetEpisodes(
 | 
				
			||||||
					ApiHelper.ParseWhere<Episode>(where),
 | 
										ApiHelper.ParseWhere<Episode>(where, x => x.ShowID == showID),
 | 
				
			||||||
					new Sort<Episode>(sortBy),
 | 
										new Sort<Episode>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -135,8 +136,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Episode> ressources = await _libraryManager.GetEpisodesFromShow(slug,
 | 
									ICollection<Episode> ressources = await _libraryManager.GetEpisodes(
 | 
				
			||||||
					ApiHelper.ParseWhere<Episode>(where),
 | 
										ApiHelper.ParseWhere<Episode>(where, x => x.Show.Slug == slug),
 | 
				
			||||||
					new Sort<Episode>(sortBy),
 | 
										new Sort<Episode>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -229,8 +230,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Genre> ressources = await _libraryManager.GetGenresFromShow(showID,
 | 
									ICollection<Genre> ressources = await _libraryManager.GetGenres(
 | 
				
			||||||
					ApiHelper.ParseWhere<Genre>(where),
 | 
										ApiHelper.ParseWhere<Genre>(where, x => x.Shows.Any(y => y.ID == showID)),
 | 
				
			||||||
					new Sort<Genre>(sortBy),
 | 
										new Sort<Genre>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -261,8 +262,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Genre> ressources = await _libraryManager.GetGenresFromShow(slug,
 | 
									ICollection<Genre> ressources = await _libraryManager.GetGenres(
 | 
				
			||||||
					ApiHelper.ParseWhere<Genre>(where),
 | 
										ApiHelper.ParseWhere<Genre>(where, x => x.Shows.Any(y => y.Slug == slug)),
 | 
				
			||||||
					new Sort<Genre>(sortBy),
 | 
										new Sort<Genre>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -284,7 +285,7 @@ namespace Kyoo.Api
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				return await _libraryManager.GetStudioFromShow(showID);
 | 
									return await _libraryManager.GetStudio(x => x.Shows.Any(y => y.ID == showID));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			catch (ItemNotFound)
 | 
								catch (ItemNotFound)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
@ -298,7 +299,7 @@ namespace Kyoo.Api
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				return await _libraryManager.GetStudioFromShow(slug);
 | 
									return await _libraryManager.GetStudio(x => x.Shows.Any(y => y.Slug == slug));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			catch (ItemNotFound)
 | 
								catch (ItemNotFound)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
@ -321,8 +322,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Library> ressources = await _libraryManager.GetLibrariesFromShow(showID,
 | 
									ICollection<Library> ressources = await _libraryManager.GetLibraries(
 | 
				
			||||||
					ApiHelper.ParseWhere<Library>(where),
 | 
										ApiHelper.ParseWhere<Library>(where, x => x.Shows.Any(y => y.ID == showID)),
 | 
				
			||||||
					new Sort<Library>(sortBy),
 | 
										new Sort<Library>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -353,8 +354,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Library> ressources = await _libraryManager.GetLibrariesFromShow(slug,
 | 
									ICollection<Library> ressources = await _libraryManager.GetLibraries(
 | 
				
			||||||
					ApiHelper.ParseWhere<Library>(where),
 | 
										ApiHelper.ParseWhere<Library>(where, x => x.Shows.Any(y => y.Slug == slug)),
 | 
				
			||||||
					new Sort<Library>(sortBy),
 | 
										new Sort<Library>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -385,8 +386,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Collection> ressources = await _libraryManager.GetCollectionsFromShow(showID,
 | 
									ICollection<Collection> ressources = await _libraryManager.GetCollections(
 | 
				
			||||||
					ApiHelper.ParseWhere<Collection>(where),
 | 
										ApiHelper.ParseWhere<Collection>(where, x => x.Shows.Any(y => y.ID == showID)),
 | 
				
			||||||
					new Sort<Collection>(sortBy),
 | 
										new Sort<Collection>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -417,8 +418,8 @@ namespace Kyoo.Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ICollection<Collection> ressources = await _libraryManager.GetCollectionsFromShow(slug,
 | 
									ICollection<Collection> ressources = await _libraryManager.GetCollections(
 | 
				
			||||||
					ApiHelper.ParseWhere<Collection>(where),
 | 
										ApiHelper.ParseWhere<Collection>(where, x => x.Shows.Any(y => y.Slug == slug)),
 | 
				
			||||||
					new Sort<Collection>(sortBy),
 | 
										new Sort<Collection>(sortBy),
 | 
				
			||||||
					new Pagination(limit, afterID));
 | 
										new Pagination(limit, afterID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user