add actors to movies and shows (#172)
* add actor metadata * show actors in ui * get full movie/show metadata from plex * store actor thumbnail url * rework movie detail page * metadata fixes * rework show detail page * rework artist page * code cleanup
This commit is contained in:
@@ -22,6 +22,10 @@ namespace ErsatzTV.Infrastructure.Data.Repositories
|
||||
_dbConnection = dbConnection;
|
||||
}
|
||||
|
||||
public Task<bool> RemoveActor(Actor actor) =>
|
||||
_dbConnection.ExecuteAsync("DELETE FROM Actor WHERE Id = @ActorId", new { ActorId = actor.Id })
|
||||
.Map(result => result > 0);
|
||||
|
||||
public async Task<bool> Update(Metadata metadata)
|
||||
{
|
||||
await using TvContext dbContext = _dbContextFactory.CreateDbContext();
|
||||
@@ -33,16 +37,44 @@ namespace ErsatzTV.Infrastructure.Data.Repositories
|
||||
{
|
||||
await using TvContext dbContext = _dbContextFactory.CreateDbContext();
|
||||
dbContext.Entry(metadata).State = EntityState.Added;
|
||||
foreach (Genre genre in metadata.Genres)
|
||||
|
||||
foreach (Genre genre in Optional(metadata.Genres).Flatten())
|
||||
{
|
||||
dbContext.Entry(genre).State = EntityState.Added;
|
||||
}
|
||||
|
||||
foreach (Tag tag in metadata.Tags)
|
||||
foreach (Tag tag in Optional(metadata.Tags).Flatten())
|
||||
{
|
||||
dbContext.Entry(tag).State = EntityState.Added;
|
||||
}
|
||||
|
||||
foreach (Studio studio in Optional(metadata.Studios).Flatten())
|
||||
{
|
||||
dbContext.Entry(studio).State = EntityState.Added;
|
||||
}
|
||||
|
||||
if (metadata is ArtistMetadata artistMetadata)
|
||||
{
|
||||
foreach (Style style in Optional(artistMetadata.Styles).Flatten())
|
||||
{
|
||||
dbContext.Entry(style).State = EntityState.Added;
|
||||
}
|
||||
|
||||
foreach (Mood mood in Optional(artistMetadata.Moods).Flatten())
|
||||
{
|
||||
dbContext.Entry(mood).State = EntityState.Added;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Actor actor in Optional(metadata.Actors).Flatten())
|
||||
{
|
||||
dbContext.Entry(actor).State = EntityState.Added;
|
||||
if (actor.Artwork != null)
|
||||
{
|
||||
dbContext.Entry(actor.Artwork).State = EntityState.Added;
|
||||
}
|
||||
}
|
||||
|
||||
return await dbContext.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user