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