GetById/Create/Update return ChannelResponseModel via new GetChannelByIdForApi
read-side query; POST /api/channels/{id:int}/playout/reset (new
GetPlayoutIdByChannelId; by-number kept for HlsSessionWorker broadcast).
Refs #288 #197
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
19 lines
718 B
C#
19 lines
718 B
C#
using ErsatzTV.Infrastructure.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ErsatzTV.Application.Playouts;
|
|
|
|
public class GetPlayoutIdByChannelIdHandler(IDbContextFactory<TvContext> dbContextFactory)
|
|
: IRequestHandler<GetPlayoutIdByChannelId, Option<int>>
|
|
{
|
|
public async Task<Option<int>> Handle(GetPlayoutIdByChannelId request, CancellationToken cancellationToken)
|
|
{
|
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
|
return await dbContext.Playouts
|
|
.Filter(p => p.Channel.Id == request.ChannelId)
|
|
.Map(p => p.Id)
|
|
.ToListAsync(cancellationToken)
|
|
.Map(list => list.HeadOrNone());
|
|
}
|
|
}
|