UpdateChannelHandler.Validate never checked incoming graphicsElementIds against
GraphicsElements, so PUT /api/v1/channels/{id} with a non-existent id hit
FK_ChannelGraphicsElement_GraphicsElement_GraphicsElementId at SaveChangesAsync
and surfaced as an unhandled 500. Add GraphicsElementIdsMustExist, following the
existing FFmpegProfileMustExist/WatermarkMustExist/FillerPresetMustExist shape,
so an unknown id now returns 422 for parity with every other FK field on this
full-replace DTO.
GetAllGraphicsElementsForApiHandler and GraphicsElementSeeder.GetBuiltInElementId
keyed builtIn off Path.GetFileName(e.Path) == OnNowNextFileName -- folder-agnostic,
so a user element named exactly on-now-next.yml in any other template folder would
also report builtIn:true. Both now compare against
GraphicsElementDefaults.OnNowNextSeededPath, the full path the seeder actually
writes to.
Follow-up from the #74 whole-branch review (2026-07-22), deferred as
data-safe/not SPA-reachable.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015QqCpYFsKgnAnx6jVwrKiV
33 lines
1.3 KiB
C#
33 lines
1.3 KiB
C#
using ErsatzTV.Core.Api.Graphics;
|
|
using ErsatzTV.Core.Domain;
|
|
using ErsatzTV.Core.Graphics;
|
|
using ErsatzTV.Infrastructure.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using static ErsatzTV.Application.Graphics.Mapper;
|
|
|
|
namespace ErsatzTV.Application.Graphics;
|
|
|
|
public class GetAllGraphicsElementsForApiHandler(IDbContextFactory<TvContext> dbContextFactory)
|
|
: IRequestHandler<GetAllGraphicsElementsForApi, List<GraphicsElementResponseModel>>
|
|
{
|
|
public async Task<List<GraphicsElementResponseModel>> Handle(
|
|
GetAllGraphicsElementsForApi request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
|
List<GraphicsElement> graphicsElements = await dbContext.GraphicsElements
|
|
.AsNoTracking()
|
|
.ToListAsync(cancellationToken);
|
|
return graphicsElements
|
|
.Select(e => new
|
|
{
|
|
Vm = ProjectToViewModel(e),
|
|
BuiltIn = e.Path == GraphicsElementDefaults.OnNowNextSeededPath
|
|
})
|
|
.OrderBy(x => x.Vm.Name == x.Vm.FileName)
|
|
.ThenBy(x => x.Vm.Name)
|
|
.Select(x => new GraphicsElementResponseModel(x.Vm.Id, x.Vm.Name, x.BuiltIn))
|
|
.ToList();
|
|
}
|
|
}
|