diff --git a/Kyoo.Common/Controllers/IRepository.cs b/Kyoo.Common/Controllers/IRepository.cs index 22f47a16..caef30a6 100644 --- a/Kyoo.Common/Controllers/IRepository.cs +++ b/Kyoo.Common/Controllers/IRepository.cs @@ -1,56 +1,18 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using System.Threading.Tasks; using JetBrains.Annotations; using Kyoo.Models; namespace Kyoo.Controllers { - public struct Pagination - { - public int Count; - public int AfterID; - } - - public readonly struct Sort - { - public string Key { get; } - public bool Descendant { get; } - - public Sort(string key, bool descendant = false) - { - Key = key; - Descendant = descendant; - } - - public Sort(Expression> key) - { - Key = Utility.GetMemberName(key); - Descendant = false; - } - - public static implicit operator Sort([NotNull] Expression> key) - { - return new Sort(Utility.GetMemberName(key)); - } - } - public interface IRepository : IDisposable, IAsyncDisposable { Task Get(int id); Task Get(string slug); Task> Search(string query); - - Task> GetAll(Expression> where = null, - Sort sort = default, - Pagination page = default); - - Task> GetAll(Expression> where = null, - Expression> sort = default, - Pagination page = default) => GetAll(where, new Sort(sort), page); - + Task> GetAll(); Task Create([NotNull] T obj); Task CreateIfNotExists([NotNull] T obj); Task Edit([NotNull] T edited, bool resetOld); diff --git a/Kyoo.Common/Models/WatchItem.cs b/Kyoo.Common/Models/WatchItem.cs index 141b139c..83b987f6 100644 --- a/Kyoo.Common/Models/WatchItem.cs +++ b/Kyoo.Common/Models/WatchItem.cs @@ -101,7 +101,7 @@ namespace Kyoo.Models if (EpisodeNumber >= episode.Season.Episodes.Count()) { NextEpisode = episode.Show.Seasons - .FirstOrDefault(x => x.SeasonNumber == SeasonNumber + 1)?.Episodes + .FirstOrDefault(x => x.SeasonNumber == SeasonNumber - 1)?.Episodes .FirstOrDefault(x => x.EpisodeNumber == 1); } else diff --git a/Kyoo.Common/Utility.cs b/Kyoo.Common/Utility.cs index 23313077..a852c6f8 100644 --- a/Kyoo.Common/Utility.cs +++ b/Kyoo.Common/Utility.cs @@ -3,7 +3,6 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Linq.Expressions; using System.Reflection; using System.Text; using System.Text.RegularExpressions; @@ -225,16 +224,5 @@ namespace Kyoo yield return ret; } } - - public static string GetMemberName(Expression> key) - { - if (key == null) - throw new ArgumentNullException(nameof(key)); - - if (!(key.Body is MemberExpression member)) - throw new ArgumentException("Key should be a member of the object."); - - return member.Member.Name; - } } } \ No newline at end of file diff --git a/Kyoo/Controllers/LibraryManager.cs b/Kyoo/Controllers/LibraryManager.cs index 8092f5c6..9b1a6590 100644 --- a/Kyoo/Controllers/LibraryManager.cs +++ b/Kyoo/Controllers/LibraryManager.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq.Expressions; using System.Threading.Tasks; using Kyoo.Models; @@ -364,7 +363,7 @@ namespace Kyoo.Controllers return _shows.Delete(show); } - public Task DeleteSeason(Season season, IShowRepository repo) + public Task DeleteSeason(Season season) { return _seasons.Delete(season); } diff --git a/Kyoo/Controllers/Repositories/CollectionRepository.cs b/Kyoo/Controllers/Repositories/CollectionRepository.cs index d183d3d6..776cc597 100644 --- a/Kyoo/Controllers/Repositories/CollectionRepository.cs +++ b/Kyoo/Controllers/Repositories/CollectionRepository.cs @@ -1,7 +1,6 @@ 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,9 +46,7 @@ namespace Kyoo.Controllers .ToListAsync(); } - public async Task> GetAll(Expression> where = null, - Sort sort = default, - Pagination page = default) + public async Task> GetAll() { return await _database.Collections.ToListAsync(); }