Fix event issue

This commit is contained in:
Zoe Roux 2023-07-23 23:32:16 +09:00
parent b753fdd2b0
commit 0f96f02df5
3 changed files with 8 additions and 4 deletions

View File

@ -80,7 +80,7 @@ namespace Kyoo.Abstractions.Models
/// <summary> /// <summary>
/// The slug of the Show that contain this episode. If this is not set, this episode is ill-formed. /// The slug of the Show that contain this episode. If this is not set, this episode is ill-formed.
/// </summary> /// </summary>
[SerializeIgnore] public string ShowSlug { private get; set; } [SerializeIgnore] public string ShowSlug { get; set; }
/// <summary> /// <summary>
/// The ID of the Show containing this episode. /// The ID of the Show containing this episode.

View File

@ -78,7 +78,11 @@ namespace Kyoo.Core.Controllers
shows.OnEdited += async (show) => shows.OnEdited += async (show) =>
{ {
foreach (Episode ep in _database.Episodes.Where(x => x.ShowID == show.ID)) foreach (Episode ep in _database.Episodes.Where(x => x.ShowID == show.ID))
{
Console.WriteLine("BFR ID: {0}; Slug: {1}; ShowSlug: {2}", ep.ID, ep.Slug, ep.ShowSlug);
ep.ShowSlug = show.Slug; ep.ShowSlug = show.Slug;
Console.WriteLine("AFT ID: {0}; Slug: {1}; ShowSlug: {2}", ep.ID, ep.Slug, ep.ShowSlug);
}
await _database.SaveChangesAsync(); await _database.SaveChangesAsync();
}; };
} }

View File

@ -350,7 +350,7 @@ namespace Kyoo.Core.Controllers
/// <param name="obj">The resource newly created.</param> /// <param name="obj">The resource newly created.</param>
protected void OnResourceCreated(T obj) protected void OnResourceCreated(T obj)
{ {
OnCreated.Invoke(obj); OnCreated?.Invoke(obj);
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -390,7 +390,7 @@ namespace Kyoo.Core.Controllers
Merger.Complete(old, edited, x => x.GetCustomAttribute<LoadableRelationAttribute>() == null); Merger.Complete(old, edited, x => x.GetCustomAttribute<LoadableRelationAttribute>() == null);
await EditRelations(old, edited, resetOld); await EditRelations(old, edited, resetOld);
await Database.SaveChangesAsync(); await Database.SaveChangesAsync();
OnEdited.Invoke(old); OnEdited?.Invoke(old);
return old; return old;
} }
finally finally
@ -469,7 +469,7 @@ namespace Kyoo.Core.Controllers
/// <inheritdoc/> /// <inheritdoc/>
public virtual Task Delete(T obj) public virtual Task Delete(T obj)
{ {
OnDeleted.Invoke(obj); OnDeleted?.Invoke(obj);
return Task.CompletedTask; return Task.CompletedTask;
} }