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> ListAllAsync() { return await _context.Collaterals.IncludeAll().ToListAsync(); } public async Task AddAsync(Collateral collateral) { var result = await _context.Collaterals.AddAsync(collateral); return result.Entity; } public async Task FindByIdAsync(int id) { return await Queryable.Where(_context.Collaterals, c => c.CollateralId == id).IncludeAll().FirstOrDefaultAsync(); } public async Task> FindByRepoIdAsync(int repoId) { return await Queryable.Where(_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); } } }