Files
ersatztv/ErsatzTV.Infrastructure/Data/Repositories/FFmpegProfileRepository.cs
T
Jason DoveandGitHub 8c9cf7b6f2 fix mid roll pad; fix mysql queries (#1416)
* fix mysql queries

* fix mid roll pad with hls segmenter
2023-09-04 10:01:39 -05:00

34 lines
1.2 KiB
C#

using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
namespace ErsatzTV.Infrastructure.Data.Repositories;
public class FFmpegProfileRepository : IFFmpegProfileRepository
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
public FFmpegProfileRepository(IDbContextFactory<TvContext> dbContextFactory) =>
_dbContextFactory = dbContextFactory;
public async Task<FFmpegProfile> Copy(int ffmpegProfileId, string name)
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync();
FFmpegProfile ffmpegProfile = await dbContext.FFmpegProfiles.FindAsync(ffmpegProfileId);
PropertyValues values = dbContext.Entry(ffmpegProfile).CurrentValues.Clone();
values["Id"] = 0;
var clone = new FFmpegProfile();
await dbContext.AddAsync(clone);
dbContext.Entry(clone).CurrentValues.SetValues(values);
clone.Name = name;
await dbContext.SaveChangesAsync();
await dbContext.Entry(clone).Reference(f => f.Resolution).LoadAsync();
return clone;
}
}