using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using LCU.Shared.Collections.RepoApiLib.Models; using LCU.Shared.Collections.RepoApiLib.Persistence; using LCU.Shared.Collections.RepoApiLib.Extensions; using Microsoft.EntityFrameworkCore; namespace LCU.Shared.Collections.RepoApiLib.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 void Update(Collateral collateral) { _context.Collaterals.Update(collateral); } public void Remove(Collateral collateral) { _context.Collaterals.Remove(collateral); } } }