using ReserveManagementSystemLib.Models; using ReserveManagementSystemLib.Persistence; namespace ReserveManagementSystemLib.Repositories { public class LoanRepository : BaseRepository, ILoanRepository { public LoanRepository(AppDbContext context) : base(context) { } public IQueryable GetAll() { return _context.Loans.Include(d => d.Dealer).Include(lt => lt.LoanType).Include("Vehicle"); } public IQueryable GetAllWithoutDealer() { return _context.Loans.Include(lt => lt.LoanType).Include("Vehicle"); } public async Task FindByIdAsync(int id) { return await _context.Loans.Where(l => l.LoanId == id).Include(d => d.Dealer).Include(lt => lt.LoanType).Include("Vehicle").FirstOrDefaultAsync(); } public Loan Add(Loan loan) { var result =_context.Loans.Add(loan); _context.SaveChanges(); return result.Entity; } public async Task UpdateAsync(IEnumerable loans) { _context.Loans.UpdateRange(loans); await _context.SaveChangesAsync(); //can use this for update and add } } }