mirror of https://github.com/ErsatzTV/ErsatzTV.git
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.
46 lines
1.5 KiB
46 lines
1.5 KiB
using System.Collections.Generic; |
|
using System.Threading.Tasks; |
|
using ErsatzTV.Core.Domain; |
|
using ErsatzTV.Core.Interfaces.Repositories; |
|
using LanguageExt; |
|
using Microsoft.EntityFrameworkCore; |
|
|
|
namespace ErsatzTV.Infrastructure.Data.Repositories |
|
{ |
|
public class FFmpegProfileRepository : IFFmpegProfileRepository |
|
{ |
|
private readonly TvContext _dbContext; |
|
|
|
public FFmpegProfileRepository(TvContext dbContext) => _dbContext = dbContext; |
|
|
|
public async Task<FFmpegProfile> Add(FFmpegProfile ffmpegProfile) |
|
{ |
|
await _dbContext.FFmpegProfiles.AddAsync(ffmpegProfile); |
|
await _dbContext.SaveChangesAsync(); |
|
return ffmpegProfile; |
|
} |
|
|
|
public async Task<Option<FFmpegProfile>> Get(int id) => |
|
await _dbContext.FFmpegProfiles |
|
.Include(p => p.Resolution) |
|
.SingleOrDefaultAsync(p => p.Id == id); |
|
|
|
public Task<List<FFmpegProfile>> GetAll() => |
|
_dbContext.FFmpegProfiles |
|
.Include(p => p.Resolution) |
|
.ToListAsync(); |
|
|
|
public async Task Update(FFmpegProfile ffmpegProfile) |
|
{ |
|
_dbContext.FFmpegProfiles.Update(ffmpegProfile); |
|
await _dbContext.SaveChangesAsync(); |
|
} |
|
|
|
public async Task Delete(int ffmpegProfileId) |
|
{ |
|
FFmpegProfile ffmpegProfile = await _dbContext.FFmpegProfiles.FindAsync(ffmpegProfileId); |
|
_dbContext.FFmpegProfiles.Remove(ffmpegProfile); |
|
await _dbContext.SaveChangesAsync(); |
|
} |
|
} |
|
}
|
|
|