Fixing a bug with libraries link

This commit is contained in:
Zoe Roux 2020-02-08 16:25:24 +01:00
parent b2471c99ae
commit f5f0a8bb61
2 changed files with 11 additions and 4 deletions

View File

@ -2,6 +2,7 @@
using Kyoo.Models.Watch; using Kyoo.Models.Watch;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace Kyoo.Controllers namespace Kyoo.Controllers
{ {
@ -194,8 +195,14 @@ namespace Kyoo.Controllers
public IEnumerable<Show> GetShowsInLibrary(long libraryID) public IEnumerable<Show> GetShowsInLibrary(long libraryID)
{ {
return (from link in _database.LibraryLinks where link.LibraryID == libraryID select link).AsEnumerable() return (from link in _database.LibraryLinks where link.LibraryID == libraryID select link)
.Select(link => link.Show ?? link.Collection.AsShow()) .AsEnumerable()
.Select(link =>
{
_database.Entry(link).Reference(l => l.Show).Load();
_database.Entry(link).Reference(l => l.Collection).Load();
return link.Show ?? link.Collection.AsShow();
})
.OrderBy(x => x.Title); .OrderBy(x => x.Title);
} }

View File

@ -33,13 +33,13 @@ namespace Kyoo
services.AddControllers().AddNewtonsoftJson(); services.AddControllers().AddNewtonsoftJson();
services.AddHttpClient(); services.AddHttpClient();
services.AddDbContext<DatabaseContext>(options => options.UseSqlite(Configuration.GetConnectionString("Database")), ServiceLifetime.Singleton); services.AddDbContext<DatabaseContext>(options => options.UseSqlite(Configuration.GetConnectionString("Database")));
// services.AddIdentity<ApplicationUser, IdentityRole>() // services.AddIdentity<ApplicationUser, IdentityRole>()
// .AddEntityFrameworkStores() // .AddEntityFrameworkStores()
// services.AddIdentityServer(); // services.AddIdentityServer();
services.AddSingleton<ILibraryManager, LibraryManager>(); services.AddScoped<ILibraryManager, LibraryManager>();
services.AddSingleton<ITranscoder, Transcoder>(); services.AddSingleton<ITranscoder, Transcoder>();
services.AddSingleton<IThumbnailsManager, ThumbnailsManager>(); services.AddSingleton<IThumbnailsManager, ThumbnailsManager>();
services.AddSingleton<IProviderManager, ProviderManager>(); services.AddSingleton<IProviderManager, ProviderManager>();