Stream custom live channels using your own media
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
753 B

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
.Include(tl => tl.Items)
.SelectOneAsync(tl => tl.Id, tl => tl.Id == request.Id)
.MapT(Mapper.ProjectToViewModel);
}
}