using ErsatzTV.Infrastructure.Data; using ErsatzTV.Infrastructure.Extensions; using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.FFmpegProfiles.Mapper; namespace ErsatzTV.Application.FFmpegProfiles; public class GetFFmpegProfileByIdHandler : IRequestHandler> { private readonly IDbContextFactory _dbContextFactory; public GetFFmpegProfileByIdHandler(IDbContextFactory dbContextFactory) => _dbContextFactory = dbContextFactory; public async Task> Handle( GetFFmpegProfileById request, CancellationToken cancellationToken) { await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken); return await dbContext.FFmpegProfiles .Include(p => p.Resolution) .SelectOneAsync(p => p.Id, p => p.Id == request.Id) .MapT(ProjectToViewModel); } }