using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; 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 RepoCompanySelectionRepository : BaseRepository, IRepoCompanySelectionRepository { public RepoCompanySelectionRepository(AppDbContext context) : base(context) {} public async Task AddAsync(RepoCompanySelection repoCompanySelection) { repoCompanySelection.Id = null; repoCompanySelection.DateTimeCreated = DateTime.Now; await _context.RepoCompanySelections.AddAsync(repoCompanySelection); } public async Task FindByIdAsync(int id) { return await _context.RepoCompanySelections.Where(repoCompanySelection => repoCompanySelection.Id == id).FirstOrDefaultAsync(); } public async Task> FindByCollateralIdAsync(int collateralId) { return await _context.RepoCompanySelections.Where(repoCompanySelection => repoCompanySelection.CollateralId == collateralId).ToListAsync(); } public async Task> ListAllAsync() { return await _context.RepoCompanySelections.ToListAsync(); } public void Remove(RepoCompanySelection repoCompanySelection) { _context.RepoCompanySelections.Remove(repoCompanySelection); } public void Update(RepoCompanySelection repoCompanySelection) { _context.RepoCompanySelections.Update(repoCompanySelection); } public void SaveRange(IList repoCompanySelections) { _context.RepoCompanySelections.UpdateRange(repoCompanySelections); } } }