Updating
This commit is contained in:
+46
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using LCU.Library.Internal.ArchiverApiLib.Extensions;
|
||||
using LCU.Library.Internal.ArchiverApiLib.Persistence;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public class ApplicationMappingRepository : BaseRepository, IApplicationMappingRepository
|
||||
{
|
||||
public ApplicationMappingRepository(AppDbContext context) : base(context) { }
|
||||
|
||||
public async Task<IEnumerable<ApplicationMapping>> ListAsync()
|
||||
{
|
||||
return await _context.ApplicationMappings.IncludeAll().ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ApplicationMapping> FindByIdAsync(int id)
|
||||
{
|
||||
return await _context.ApplicationMappings.Where(applicationMapping => applicationMapping.ApplicationMappingId == id).IncludeAll().FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ApplicationMapping>> FindByIdentifierAsync(string identifier)
|
||||
{
|
||||
return await _context.ApplicationMappings.Where(applicationMapping => applicationMapping.Identifier == identifier).IncludeAll().ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ApplicationMapping> AddAsync(ApplicationMapping applicationMapping)
|
||||
{
|
||||
var result = await _context.ApplicationMappings.AddAsync(applicationMapping);
|
||||
return result.Entity;
|
||||
}
|
||||
|
||||
public void Update(ApplicationMapping applicationMapping)
|
||||
{
|
||||
_context.ApplicationMappings.Update(applicationMapping);
|
||||
}
|
||||
|
||||
public void Remove(ApplicationMapping applicationMapping)
|
||||
{
|
||||
_context.ApplicationMappings.Remove(applicationMapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using LCU.Library.Internal.ArchiverApiLib.Persistence;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public abstract class BaseRepository
|
||||
{
|
||||
protected readonly AppDbContext _context;
|
||||
|
||||
public BaseRepository(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public interface IApplicationMappingRepository
|
||||
{
|
||||
Task<IEnumerable<ApplicationMapping>> ListAsync();
|
||||
Task<ApplicationMapping> FindByIdAsync(int id);
|
||||
Task<IEnumerable<ApplicationMapping>> FindByIdentifierAsync(string identifier);
|
||||
Task<ApplicationMapping> AddAsync(ApplicationMapping applicationMapping);
|
||||
void Update(ApplicationMapping applicationMapping);
|
||||
void Remove(ApplicationMapping applicationMapping);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public interface IRegexMappingRepository
|
||||
{
|
||||
Task<IEnumerable<RegexMapping>> ListAsync();
|
||||
Task<RegexMapping> FindByApplicationMappingIdAsync(int id);
|
||||
Task<RegexMapping> FindByRegexMappingIdAsync(int id);
|
||||
Task<RegexMapping> AddAsync(RegexMapping regexMapping);
|
||||
void Update(RegexMapping regexMapping);
|
||||
void Remove(RegexMapping regexMapping);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public interface IUnitOfWork
|
||||
{
|
||||
Task CompleteAsync();
|
||||
void Complete();
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
using LCU.Library.Internal.ArchiverApiLib.Persistence;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public class UnitOfWork : IUnitOfWork
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public UnitOfWork(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task CompleteAsync()
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public void Complete()
|
||||
{
|
||||
_context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user