* add initial models * migrations * edit break content mode * add and remove break content from ui * use autocompletes in deco editor * save break content to db * allow break content playlists * refactor default filler build * fix slow startup * start to implement adding break content * use clone; try to fix block breaks * fix updating history * use consistent removebefore values * cleanup logging * only allow playlist break content * update changelog
86 lines
3.7 KiB
C#
86 lines
3.7 KiB
C#
using ErsatzTV.Core.Domain;
|
|
using ErsatzTV.Infrastructure.Data;
|
|
using ErsatzTV.Infrastructure.Extensions;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ErsatzTV.Application.Scheduling;
|
|
|
|
public class GetDecoByIdHandler(IDbContextFactory<TvContext> dbContextFactory)
|
|
: IRequestHandler<GetDecoById, Option<DecoViewModel>>
|
|
{
|
|
public async Task<Option<DecoViewModel>> Handle(GetDecoById request, CancellationToken cancellationToken)
|
|
{
|
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
|
return await dbContext.Decos
|
|
.AsNoTracking()
|
|
.Include(d => d.DecoGroup)
|
|
.Include(d => d.DecoWatermarks)
|
|
.ThenInclude(d => d.Watermark)
|
|
.Include(d => d.DecoGraphicsElements)
|
|
.ThenInclude(d => d.GraphicsElement)
|
|
|
|
.Include(d => d.BreakContent)
|
|
.ThenInclude(bc => bc.Collection)
|
|
.Include(d => d.BreakContent)
|
|
.ThenInclude(bc => bc.MediaItem)
|
|
.ThenInclude(i => (i as Season).SeasonMetadata)
|
|
.ThenInclude(sm => sm.Artwork)
|
|
.Include(d => d.BreakContent)
|
|
.ThenInclude(bc => bc.MediaItem)
|
|
.ThenInclude(i => (i as Season).Show)
|
|
.ThenInclude(s => s.ShowMetadata)
|
|
.ThenInclude(sm => sm.Artwork)
|
|
.Include(d => d.BreakContent)
|
|
.ThenInclude(bc => bc.MediaItem)
|
|
.ThenInclude(i => (i as Show).ShowMetadata)
|
|
.ThenInclude(sm => sm.Artwork)
|
|
.Include(d => d.BreakContent)
|
|
.ThenInclude(bc => bc.MediaItem)
|
|
.ThenInclude(i => (i as Artist).ArtistMetadata)
|
|
.ThenInclude(am => am.Artwork)
|
|
.Include(d => d.BreakContent)
|
|
.ThenInclude(bc => bc.MultiCollection)
|
|
.Include(d => d.BreakContent)
|
|
.ThenInclude(bc => bc.SmartCollection)
|
|
.Include(d => d.BreakContent)
|
|
.ThenInclude(bc => bc.Playlist)
|
|
|
|
.Include(d => d.DefaultFillerCollection)
|
|
.Include(d => d.DefaultFillerMultiCollection)
|
|
.Include(d => d.DefaultFillerSmartCollection)
|
|
.Include(d => d.DefaultFillerMediaItem)
|
|
.ThenInclude(i => (i as Season).SeasonMetadata)
|
|
.ThenInclude(sm => sm.Artwork)
|
|
.Include(i => i.DefaultFillerMediaItem)
|
|
.ThenInclude(i => (i as Season).Show)
|
|
.ThenInclude(s => s.ShowMetadata)
|
|
.ThenInclude(sm => sm.Artwork)
|
|
.Include(i => i.DefaultFillerMediaItem)
|
|
.ThenInclude(i => (i as Show).ShowMetadata)
|
|
.ThenInclude(sm => sm.Artwork)
|
|
.Include(i => i.DefaultFillerMediaItem)
|
|
.ThenInclude(i => (i as Artist).ArtistMetadata)
|
|
.ThenInclude(am => am.Artwork)
|
|
|
|
.Include(d => d.DeadAirFallbackCollection)
|
|
.Include(d => d.DeadAirFallbackMultiCollection)
|
|
.Include(d => d.DeadAirFallbackSmartCollection)
|
|
.Include(d => d.DeadAirFallbackMediaItem)
|
|
.ThenInclude(i => (i as Season).SeasonMetadata)
|
|
.ThenInclude(sm => sm.Artwork)
|
|
.Include(i => i.DeadAirFallbackMediaItem)
|
|
.ThenInclude(i => (i as Season).Show)
|
|
.ThenInclude(s => s.ShowMetadata)
|
|
.ThenInclude(sm => sm.Artwork)
|
|
.Include(i => i.DeadAirFallbackMediaItem)
|
|
.ThenInclude(i => (i as Show).ShowMetadata)
|
|
.ThenInclude(sm => sm.Artwork)
|
|
.Include(i => i.DeadAirFallbackMediaItem)
|
|
.ThenInclude(i => (i as Artist).ArtistMetadata)
|
|
.ThenInclude(am => am.Artwork)
|
|
|
|
.SelectOneAsync(b => b.Id, b => b.Id == request.DecoId, cancellationToken)
|
|
.MapT(Mapper.ProjectToViewModel);
|
|
}
|
|
}
|