mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-23 15:30:34 -04:00
Fixing others's repository edit
This commit is contained in:
parent
4b56ec4114
commit
cfc3e4b865
@ -168,9 +168,7 @@ namespace Kyoo.Controllers
|
||||
{
|
||||
if (resource.ShowID <= 0)
|
||||
throw new InvalidOperationException($"Can't store an episode not related to any show (showID: {resource.ShowID}).");
|
||||
|
||||
await base.EditRelations(resource, changed, resetOld);
|
||||
|
||||
|
||||
if (changed.Tracks != null || resetOld)
|
||||
{
|
||||
ICollection<Track> oldTracks = await _tracks.GetAll(x => x.EpisodeID == resource.ID);
|
||||
@ -190,7 +188,11 @@ namespace Kyoo.Controllers
|
||||
if (changed.ExternalIDs != null || resetOld)
|
||||
{
|
||||
await Database.Entry(resource).Collection(x => x.ExternalIDs).LoadAsync();
|
||||
resource.ExternalIDs = changed.ExternalIDs;
|
||||
resource.ExternalIDs = changed.ExternalIDs?.Select(x =>
|
||||
{
|
||||
x.Provider = null;
|
||||
return x;
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,9 +79,11 @@ namespace Kyoo.Controllers
|
||||
throw new ArgumentException("The library should have a least one path.");
|
||||
|
||||
if (changed.Providers != null || resetOld)
|
||||
{
|
||||
await Validate(changed);
|
||||
await Database.Entry(resource).Collection(x => x.Providers).LoadAsync();
|
||||
resource.Providers = changed.Providers;
|
||||
await base.EditRelations(resource, changed, resetOld);
|
||||
resource.Providers = changed.Providers;
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task Delete(Library obj)
|
||||
|
@ -71,20 +71,33 @@ namespace Kyoo.Controllers
|
||||
protected override async Task Validate(People resource)
|
||||
{
|
||||
await base.Validate(resource);
|
||||
await resource.ExternalIDs.ForEachAsync(async id =>
|
||||
id.Provider = await _providers.CreateIfNotExists(id.Provider, true));
|
||||
await resource.ExternalIDs.ForEachAsync(async id =>
|
||||
{
|
||||
id.ProviderID = (await _providers.CreateIfNotExists(id.Provider, true)).ID;
|
||||
id.Provider = null;
|
||||
|
||||
});
|
||||
await resource.Roles.ForEachAsync(async role =>
|
||||
role.Show = await _shows.Value.CreateIfNotExists(role.Show, true));
|
||||
{
|
||||
role.ShowID = (await _shows.Value.CreateIfNotExists(role.Show, true)).ID;
|
||||
role.Show = null;
|
||||
});
|
||||
}
|
||||
|
||||
protected override async Task EditRelations(People resource, People changed, bool resetOld)
|
||||
{
|
||||
if (changed.Roles != null || resetOld)
|
||||
{
|
||||
await Database.Entry(resource).Collection(x => x.Roles).LoadAsync();
|
||||
resource.Roles = changed.Roles;
|
||||
resource.Roles = changed.Roles;
|
||||
}
|
||||
|
||||
if (changed.ExternalIDs != null || resetOld)
|
||||
{
|
||||
await Database.Entry(resource).Collection(x => x.ExternalIDs).LoadAsync();
|
||||
resource.ExternalIDs = changed.ExternalIDs;
|
||||
resource.ExternalIDs = changed.ExternalIDs;
|
||||
|
||||
}
|
||||
await base.EditRelations(resource, changed, resetOld);
|
||||
}
|
||||
|
||||
|
@ -138,15 +138,20 @@ namespace Kyoo.Controllers
|
||||
throw new InvalidOperationException($"Can't store a season not related to any show (showID: {resource.ShowID}).");
|
||||
|
||||
await base.Validate(resource);
|
||||
await resource.ExternalIDs.ForEachAsync(async id =>
|
||||
id.Provider = await _providers.CreateIfNotExists(id.Provider, true));
|
||||
await resource.ExternalIDs.ForEachAsync(async id =>
|
||||
{
|
||||
id.ProviderID = (await _providers.CreateIfNotExists(id.Provider, true)).ID;
|
||||
id.Provider = null;
|
||||
});
|
||||
}
|
||||
|
||||
protected override async Task EditRelations(Season resource, Season changed, bool resetOld)
|
||||
{
|
||||
if (changed.ExternalIDs != null || resetOld)
|
||||
{
|
||||
await Database.Entry(resource).Collection(x => x.ExternalIDs).LoadAsync();
|
||||
resource.ExternalIDs = changed.ExternalIDs;
|
||||
resource.ExternalIDs = changed.ExternalIDs;
|
||||
}
|
||||
await base.EditRelations(resource, changed, resetOld);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user