Adding
This commit is contained in:
+46
@@ -0,0 +1,46 @@
|
||||
using LCU.API.Internal.RepoApi.Repos.Extensions;
|
||||
using LCU.API.Internal.RepoApi.Repos.Models;
|
||||
using LCU.API.Internal.RepoApi.Repos.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LCU.API.Internal.RepoApi.Repos.Repositories
|
||||
{
|
||||
public class CollateralRepository : BaseRepository, ICollateralRepository
|
||||
{
|
||||
|
||||
public CollateralRepository(AppDbContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Collateral>> ListAllAsync()
|
||||
{
|
||||
return await _context.Collaterals.IncludeAll().ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Collateral> AddAsync(Collateral collateral)
|
||||
{
|
||||
var result = await _context.Collaterals.AddAsync(collateral);
|
||||
return result.Entity;
|
||||
}
|
||||
|
||||
public async Task<Collateral> FindByIdAsync(int id)
|
||||
{
|
||||
return await Queryable.Where<Collateral>(_context.Collaterals, c => c.CollateralId == id).IncludeAll().FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Collateral>> FindByRepoIdAsync(int repoId)
|
||||
{
|
||||
return await Queryable.Where<Collateral>(_context.Collaterals, c => c.RepoId == repoId).IncludeAll().ToListAsync();
|
||||
}
|
||||
|
||||
public void Update(Collateral collateral)
|
||||
{
|
||||
_context.Collaterals.Update(collateral);
|
||||
}
|
||||
|
||||
public void Remove(Collateral collateral)
|
||||
{
|
||||
_context.Collaterals.Remove(collateral);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user