Files
ersatztv/ErsatzTV.Application/MediaCollections/Queries/GetTraktListByIdHandler.cs
T
Jason DoveandGitHub 1c07df5bc3 use cancellation tokens in many places (#2350)
* use cancellation tokens everywhere

* more cancellation tokens
2025-08-27 03:20:35 +00:00

20 lines
800 B
C#

using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Application.MediaCollections;
public class GetTraktListByIdHandler(IDbContextFactory<TvContext> dbContextFactory)
: IRequestHandler<GetTraktListById, Option<TraktListViewModel>>
{
public async Task<Option<TraktListViewModel>> Handle(GetTraktListById request, CancellationToken cancellationToken)
{
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
return await dbContext.TraktLists
.AsNoTracking()
.Include(tl => tl.Items)
.SelectOneAsync(tl => tl.Id, tl => tl.Id == request.Id, cancellationToken)
.MapT(Mapper.ProjectToViewModel);
}
}