using System.Threading; using System.Threading.Tasks; using ErsatzTV.Infrastructure.Data; using ErsatzTV.Infrastructure.Extensions; using LanguageExt; using MediatR; using Microsoft.EntityFrameworkCore; using static ErsatzTV.Application.FFmpegProfiles.Mapper; namespace ErsatzTV.Application.FFmpegProfiles.Queries { 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 = _dbContextFactory.CreateDbContext(); return await dbContext.FFmpegProfiles .Include(p => p.Resolution) .SelectOneAsync(p => p.Id, p => p.Id == request.Id) .MapT(ProjectToViewModel); } } }