mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Adding parameters everywhere
This commit is contained in:
parent
3eaf4c005a
commit
38bb0a2efe
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Kyoo.Models;
|
||||
@ -36,16 +38,78 @@ namespace Kyoo.Controllers
|
||||
Task AddShowLink([NotNull] Show show, Library library, Collection collection);
|
||||
|
||||
// Get all
|
||||
Task<ICollection<Library>> GetLibraries();
|
||||
Task<ICollection<Collection>> GetCollections();
|
||||
Task<ICollection<Show>> GetShows();
|
||||
Task<ICollection<Season>> GetSeasons();
|
||||
Task<ICollection<Episode>> GetEpisodes();
|
||||
Task<ICollection<Track>> GetTracks();
|
||||
Task<ICollection<Studio>> GetStudios();
|
||||
Task<ICollection<People>> GetPeoples();
|
||||
Task<ICollection<Genre>> GetGenres();
|
||||
Task<ICollection<ProviderID>> GetProviders();
|
||||
Task<ICollection<Library>> GetLibraries(Expression<Func<Library, bool>> where = null,
|
||||
Sort<Library> sort = default,
|
||||
Pagination page = default);
|
||||
Task<ICollection<Collection>> GetCollections(Expression<Func<Collection, bool>> where = null,
|
||||
Sort<Collection> sort = default,
|
||||
Pagination page = default);
|
||||
Task<ICollection<Show>> GetShows(Expression<Func<Show, bool>> where = null,
|
||||
Sort<Show> sort = default,
|
||||
Pagination page = default);
|
||||
Task<ICollection<Season>> GetSeasons(Expression<Func<Season, bool>> where = null,
|
||||
Sort<Season> sort = default,
|
||||
Pagination page = default);
|
||||
Task<ICollection<Episode>> GetEpisodes(Expression<Func<Episode, bool>> where = null,
|
||||
Sort<Episode> sort = default,
|
||||
Pagination page = default);
|
||||
Task<ICollection<Track>> GetTracks(Expression<Func<Track, bool>> where = null,
|
||||
Sort<Track> sort = default,
|
||||
Pagination page = default);
|
||||
Task<ICollection<Studio>> GetStudios(Expression<Func<Studio, bool>> where = null,
|
||||
Sort<Studio> sort = default,
|
||||
Pagination page = default);
|
||||
Task<ICollection<People>> GetPeople(Expression<Func<People, bool>> where = null,
|
||||
Sort<People> sort = default,
|
||||
Pagination page = default);
|
||||
Task<ICollection<Genre>> GetGenres(Expression<Func<Genre, bool>> where = null,
|
||||
Sort<Genre> sort = default,
|
||||
Pagination page = default);
|
||||
Task<ICollection<ProviderID>> GetProviders(Expression<Func<ProviderID, bool>> where = null,
|
||||
Sort<ProviderID> sort = default,
|
||||
Pagination page = default);
|
||||
|
||||
Task<ICollection<Library>> GetLibraries([Optional] Expression<Func<Library, bool>> where,
|
||||
Expression<Func<Library, object>> sort,
|
||||
Pagination page = default
|
||||
) => GetLibraries(where, new Sort<Library>(sort), page);
|
||||
Task<ICollection<Collection>> GetCollections([Optional] Expression<Func<Collection, bool>> where,
|
||||
Expression<Func<Collection, object>> sort,
|
||||
Pagination page = default
|
||||
) => GetCollections(where, new Sort<Collection>(sort), page);
|
||||
Task<ICollection<Show>> GetShows([Optional] Expression<Func<Show, bool>> where,
|
||||
Expression<Func<Show, object>> sort,
|
||||
Pagination page = default
|
||||
) => GetShows(where, new Sort<Show>(sort), page);
|
||||
Task<ICollection<Season>> GetSeasons([Optional] Expression<Func<Season, bool>> where,
|
||||
Expression<Func<Season, object>> sort,
|
||||
Pagination page = default
|
||||
) => GetSeasons(where, new Sort<Season>(sort), page);
|
||||
Task<ICollection<Episode>> GetEpisodes([Optional] Expression<Func<Episode, bool>> where,
|
||||
Expression<Func<Episode, object>> sort,
|
||||
Pagination page = default
|
||||
) => GetEpisodes(where, new Sort<Episode>(sort), page);
|
||||
Task<ICollection<Track>> GetTracks([Optional] Expression<Func<Track, bool>> where,
|
||||
Expression<Func<Track, object>> sort,
|
||||
Pagination page = default
|
||||
) => GetTracks(where, new Sort<Track>(sort), page);
|
||||
Task<ICollection<Studio>> GetStudios([Optional] Expression<Func<Studio, bool>> where,
|
||||
Expression<Func<Studio, object>> sort,
|
||||
Pagination page = default
|
||||
) => GetStudios(where, new Sort<Studio>(sort), page);
|
||||
Task<ICollection<People>> GetPeople([Optional] Expression<Func<People, bool>> where,
|
||||
Expression<Func<People, object>> sort,
|
||||
Pagination page = default
|
||||
) => GetPeople(where, new Sort<People>(sort), page);
|
||||
Task<ICollection<Genre>> GetGenres([Optional] Expression<Func<Genre, bool>> where,
|
||||
Expression<Func<Genre, object>> sort,
|
||||
Pagination page = default
|
||||
) => GetGenres(where, new Sort<Genre>(sort), page);
|
||||
Task<ICollection<ProviderID>> GetProviders([Optional] Expression<Func<ProviderID, bool>> where,
|
||||
Expression<Func<ProviderID, object>> sort,
|
||||
Pagination page = default
|
||||
) => GetProviders(where, new Sort<ProviderID>(sort), page);
|
||||
|
||||
|
||||
// Search
|
||||
Task<ICollection<Library>> SearchLibraries(string searchQuery);
|
||||
|
@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Kyoo.Models;
|
||||
@ -42,8 +43,8 @@ namespace Kyoo.Controllers
|
||||
Sort<T> sort = default,
|
||||
Pagination page = default);
|
||||
|
||||
Task<ICollection<T>> GetAll(Expression<Func<T, bool>> where = null,
|
||||
Expression<Func<T, object>> sort = default,
|
||||
Task<ICollection<T>> GetAll([Optional] Expression<Func<T, bool>> where,
|
||||
Expression<Func<T, object>> sort,
|
||||
Pagination page = default
|
||||
) => GetAll(where, new Sort<T>(sort), page);
|
||||
|
||||
|
@ -127,54 +127,74 @@ namespace Kyoo.Controllers
|
||||
return _people.Get(slug);
|
||||
}
|
||||
|
||||
public Task<ICollection<Library>> GetLibraries()
|
||||
public Task<ICollection<Library>> GetLibraries(Expression<Func<Library, bool>> where = null,
|
||||
Sort<Library> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return _libraries.GetAll();
|
||||
return _libraries.GetAll(where, sort, page);
|
||||
}
|
||||
|
||||
public Task<ICollection<Collection>> GetCollections()
|
||||
public Task<ICollection<Collection>> GetCollections(Expression<Func<Collection, bool>> where = null,
|
||||
Sort<Collection> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return _collections.GetAll();
|
||||
return _collections.GetAll(where, sort, page);
|
||||
}
|
||||
|
||||
public Task<ICollection<Show>> GetShows()
|
||||
public Task<ICollection<Show>> GetShows(Expression<Func<Show, bool>> where = null,
|
||||
Sort<Show> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return _shows.GetAll();
|
||||
return _shows.GetAll(where, sort, page);
|
||||
}
|
||||
|
||||
public Task<ICollection<Season>> GetSeasons()
|
||||
public Task<ICollection<Season>> GetSeasons(Expression<Func<Season, bool>> where = null,
|
||||
Sort<Season> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return _seasons.GetAll();
|
||||
return _seasons.GetAll(where, sort, page);
|
||||
}
|
||||
|
||||
public Task<ICollection<Episode>> GetEpisodes()
|
||||
public Task<ICollection<Episode>> GetEpisodes(Expression<Func<Episode, bool>> where = null,
|
||||
Sort<Episode> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return _episodes.GetAll();
|
||||
return _episodes.GetAll(where, sort, page);
|
||||
}
|
||||
|
||||
public Task<ICollection<Track>> GetTracks()
|
||||
public Task<ICollection<Track>> GetTracks(Expression<Func<Track, bool>> where = null,
|
||||
Sort<Track> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return _tracks.GetAll();
|
||||
return _tracks.GetAll(where, sort, page);
|
||||
}
|
||||
|
||||
public Task<ICollection<Studio>> GetStudios()
|
||||
public Task<ICollection<Studio>> GetStudios(Expression<Func<Studio, bool>> where = null,
|
||||
Sort<Studio> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return _studios.GetAll();
|
||||
return _studios.GetAll(where, sort, page);
|
||||
}
|
||||
|
||||
public Task<ICollection<People>> GetPeoples()
|
||||
public Task<ICollection<People>> GetPeoples(Expression<Func<People, bool>> where = null,
|
||||
Sort<People> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return _people.GetAll();
|
||||
return _people.GetAll(where, sort, page);
|
||||
}
|
||||
|
||||
public Task<ICollection<Genre>> GetGenres()
|
||||
public Task<ICollection<Genre>> GetGenres(Expression<Func<Genre, bool>> where = null,
|
||||
Sort<Genre> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return _genres.GetAll();
|
||||
return _genres.GetAll(where, sort, page);
|
||||
}
|
||||
|
||||
public Task<ICollection<ProviderID>> GetProviders()
|
||||
public Task<ICollection<ProviderID>> GetProviders(Expression<Func<ProviderID, bool>> where = null,
|
||||
Sort<ProviderID> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return _providers.GetAll();
|
||||
return _providers.GetAll(where, sort, page);
|
||||
}
|
||||
|
||||
public Task<ICollection<Season>> GetSeasons(int showID)
|
||||
@ -364,7 +384,7 @@ namespace Kyoo.Controllers
|
||||
return _shows.Delete(show);
|
||||
}
|
||||
|
||||
public Task DeleteSeason(Season season, IShowRepository repo)
|
||||
public Task DeleteSeason(Season season)
|
||||
{
|
||||
return _seasons.Delete(season);
|
||||
}
|
||||
|
@ -56,10 +56,18 @@ namespace Kyoo.Controllers
|
||||
if (where != null)
|
||||
query = query.Where(where);
|
||||
|
||||
Expression<Func<Collection, object>> sortOrder = sort.Key ?? (x => x.Name);
|
||||
query = sort.Descendant ? query.OrderByDescending(sortOrder) : query.OrderBy(sortOrder);
|
||||
Expression<Func<Collection, object>> sortKey = sort.Key ?? (x => x.Name);
|
||||
query = sort.Descendant ? query.OrderByDescending(sortKey) : query.OrderBy(sortKey);
|
||||
|
||||
query.Where(x => x.ID )
|
||||
if (page.AfterID != 0)
|
||||
{
|
||||
Collection after = await Get(page.AfterID);
|
||||
object afterObj = sortKey.Compile()(after);
|
||||
query = query.Where(Expression.Lambda<Func<Collection, bool>>(
|
||||
Expression.GreaterThan(sortKey, Expression.Constant(afterObj))
|
||||
));
|
||||
}
|
||||
query = query.Take(page.Count <= 0 ? 20 : page.Count);
|
||||
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
@ -69,7 +70,9 @@ namespace Kyoo.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Episode>> GetAll()
|
||||
public async Task<ICollection<Episode>> GetAll(Expression<Func<Episode, bool>> where = null,
|
||||
Sort<Episode> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return await _database.Episodes.ToListAsync();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
@ -46,7 +47,9 @@ namespace Kyoo.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Genre>> GetAll()
|
||||
public async Task<ICollection<Genre>> GetAll(Expression<Func<Genre, bool>> where = null,
|
||||
Sort<Genre> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return await _database.Genres.ToListAsync();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
@ -48,7 +49,9 @@ namespace Kyoo.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Library>> GetAll()
|
||||
public async Task<ICollection<Library>> GetAll(Expression<Func<Library, bool>> where = null,
|
||||
Sort<Library> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return await _database.Libraries.ToListAsync();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
@ -47,7 +48,9 @@ namespace Kyoo.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ICollection<People>> GetAll()
|
||||
public async Task<ICollection<People>> GetAll(Expression<Func<People, bool>> where = null,
|
||||
Sort<People> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return await _database.Peoples.ToListAsync();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
@ -46,7 +47,9 @@ namespace Kyoo.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ICollection<ProviderID>> GetAll()
|
||||
public async Task<ICollection<ProviderID>> GetAll(Expression<Func<ProviderID, bool>> where = null,
|
||||
Sort<ProviderID> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return await _database.Providers.ToListAsync();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
@ -62,7 +63,9 @@ namespace Kyoo.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Season>> GetAll()
|
||||
public async Task<ICollection<Season>> GetAll(Expression<Func<Season, bool>> where = null,
|
||||
Sort<Season> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return await _database.Seasons.ToListAsync();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
@ -70,7 +71,9 @@ namespace Kyoo.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Show>> GetAll()
|
||||
public async Task<ICollection<Show>> GetAll(Expression<Func<Show, bool>> where = null,
|
||||
Sort<Show> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return await _database.Shows.ToListAsync();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
@ -46,7 +47,9 @@ namespace Kyoo.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Studio>> GetAll()
|
||||
public async Task<ICollection<Studio>> GetAll(Expression<Func<Studio, bool>> where = null,
|
||||
Sort<Studio> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return await _database.Studios.ToListAsync();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
@ -49,7 +50,9 @@ namespace Kyoo.Controllers
|
||||
throw new InvalidOperationException("Tracks do not support the search method.");
|
||||
}
|
||||
|
||||
public async Task<ICollection<Track>> GetAll()
|
||||
public async Task<ICollection<Track>> GetAll(Expression<Func<Track, bool>> where = null,
|
||||
Sort<Track> sort = default,
|
||||
Pagination page = default)
|
||||
{
|
||||
return await _database.Tracks.ToListAsync();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user