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>
/// The slug of the Show that contain this episode. If this is not set, this episode is ill-formed.
/// </summary>
[SerializeIgnore] public string ShowSlug { private get; set; }
[SerializeIgnore] public string ShowSlug { get; set; }
/// <summary>
/// The ID of the Show containing this episode.

View File

@ -78,7 +78,11 @@ namespace Kyoo.Core.Controllers
shows.OnEdited += async (show) =>
{
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;
Console.WriteLine("AFT ID: {0}; Slug: {1}; ShowSlug: {2}", ep.ID, ep.Slug, ep.ShowSlug);
}
await _database.SaveChangesAsync();
};
}

View File

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