mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Handling external ids
This commit is contained in:
parent
b59f208781
commit
4414d94c7e
@ -35,4 +35,5 @@ namespace Kyoo.Controllers
|
||||
public interface IGenreRepository : IRepository<Genre> {}
|
||||
public interface IStudioRepository : IRepository<Studio> {}
|
||||
public interface IPeopleRepository : IRepository<People> {}
|
||||
public interface IProviderRepository : IRepository<ProviderID> {}
|
||||
}
|
@ -14,16 +14,19 @@ namespace Kyoo.Controllers
|
||||
private readonly IGenreRepository _genres;
|
||||
private readonly IPeopleRepository _people;
|
||||
private readonly IStudioRepository _studio;
|
||||
private readonly IProviderRepository _providers;
|
||||
|
||||
public ShowRepository(DatabaseContext database,
|
||||
IGenreRepository genres,
|
||||
IPeopleRepository people,
|
||||
IStudioRepository studio)
|
||||
IStudioRepository studio,
|
||||
IProviderRepository providers)
|
||||
{
|
||||
_database = database;
|
||||
_genres = genres;
|
||||
_people = people;
|
||||
_studio = studio;
|
||||
_providers = providers;
|
||||
}
|
||||
|
||||
public Task<Show> Get(long id)
|
||||
@ -52,8 +55,7 @@ namespace Kyoo.Controllers
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
|
||||
// TODO handle ExternalIDs.
|
||||
|
||||
obj.StudioID = await _studio.CreateIfNotExists(obj.Studio);
|
||||
obj.GenreLinks = (await Task.WhenAll(obj.GenreLinks.Select(async x =>
|
||||
{
|
||||
@ -65,6 +67,11 @@ namespace Kyoo.Controllers
|
||||
x.PeopleID = await _people.CreateIfNotExists(x.People);
|
||||
return x;
|
||||
}))).ToList();
|
||||
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
||||
{
|
||||
x.ProviderID = await _providers.CreateIfNotExists(x.Provider);
|
||||
return x;
|
||||
}))).ToList();
|
||||
|
||||
obj.Seasons = null;
|
||||
obj.Episodes = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user