47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using LCU.Library.Internal.ArchiverApiLib.Persistence;
|
|
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System.Threading.Tasks;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using LCU.Library.Internal.ArchiverApiLib.Extensions;
|
|
|
|
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
|
{
|
|
public class RegexMappingRepository : BaseRepository, IRegexMappingRepository
|
|
{
|
|
public RegexMappingRepository(AppDbContext context) : base(context) { }
|
|
|
|
public async Task<RegexMapping> AddAsync(RegexMapping regexMapping)
|
|
{
|
|
var result = await _context.RegexMappings.AddAsync(regexMapping);
|
|
return result.Entity;
|
|
}
|
|
|
|
public async Task<RegexMapping> FindByApplicationMappingIdAsync(int id)
|
|
{
|
|
return await _context.RegexMappings.Where(regexMapping => regexMapping.ApplicationMappingId == id).FirstOrDefaultAsync();
|
|
}
|
|
|
|
public async Task<RegexMapping> FindByRegexMappingIdAsync(int id)
|
|
{
|
|
return await _context.RegexMappings.Where(regexMapping => regexMapping.RegexMappingId == id).FirstOrDefaultAsync();
|
|
}
|
|
|
|
public async Task<IEnumerable<RegexMapping>> ListAsync()
|
|
{
|
|
return await _context.RegexMappings.ToListAsync();
|
|
}
|
|
|
|
public void Remove(RegexMapping regexMapping)
|
|
{
|
|
_context.RegexMappings.Remove(regexMapping);
|
|
}
|
|
|
|
public void Update(RegexMapping regexMapping)
|
|
{
|
|
_context.RegexMappings.Update(regexMapping);
|
|
}
|
|
}
|
|
}
|