mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix season and episode slugs on update
This commit is contained in:
parent
5a6da7441f
commit
4688868f04
@ -71,14 +71,6 @@ public class EpisodeRepository(
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task<Episode> Create(Episode obj)
|
||||
{
|
||||
// Set it for the OnResourceCreated event and the return value.
|
||||
obj.ShowSlug = obj.Show?.Slug ?? (await shows.Get(obj.ShowId)).Slug;
|
||||
return await base.Create(obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task Validate(Episode resource)
|
||||
{
|
||||
@ -86,6 +78,9 @@ public class EpisodeRepository(
|
||||
resource.Show = null;
|
||||
if (resource.ShowId == Guid.Empty)
|
||||
throw new ValidationException("Missing show id");
|
||||
// This is storred in db so it needs to be set before every create/edit (and before events)
|
||||
resource.ShowSlug = (await shows.Get(resource.ShowId)).Slug;
|
||||
|
||||
resource.Season = null;
|
||||
if (resource.SeasonId == null && resource.SeasonNumber != null)
|
||||
{
|
||||
|
@ -31,8 +31,11 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Kyoo.Core.Controllers;
|
||||
|
||||
public class SeasonRepository(DatabaseContext database, IThumbnailsManager thumbnails)
|
||||
: GenericRepository<Season>(database)
|
||||
public class SeasonRepository(
|
||||
DatabaseContext database,
|
||||
IRepository<Show> shows,
|
||||
IThumbnailsManager thumbnails
|
||||
) : GenericRepository<Season>(database)
|
||||
{
|
||||
static SeasonRepository()
|
||||
{
|
||||
@ -66,16 +69,6 @@ public class SeasonRepository(DatabaseContext database, IThumbnailsManager thumb
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task<Season> Create(Season obj)
|
||||
{
|
||||
// Set it for the OnResourceCreated event and the return value.
|
||||
obj.ShowSlug =
|
||||
(await Database.Shows.FirstOrDefaultAsync(x => x.Id == obj.ShowId))?.Slug
|
||||
?? throw new ItemNotFoundException($"No show found with ID {obj.ShowId}");
|
||||
return await base.Create(obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override async Task Validate(Season resource)
|
||||
{
|
||||
@ -83,6 +76,8 @@ public class SeasonRepository(DatabaseContext database, IThumbnailsManager thumb
|
||||
resource.Show = null;
|
||||
if (resource.ShowId == Guid.Empty)
|
||||
throw new ValidationException("Missing show id");
|
||||
// This is storred in db so it needs to be set before every create/edit (and before events)
|
||||
resource.ShowSlug = (await shows.Get(resource.ShowId)).Slug;
|
||||
await thumbnails.DownloadImages(resource);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user