46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
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);
|
|
}
|
|
}
|
|
} |