Files
2026-04-20 14:47:24 -05:00

53 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.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<RepoCompanySelection> FindByIdAsync(int id)
{
return await _context.RepoCompanySelections.Where(repoCompanySelection => repoCompanySelection.Id == id).FirstOrDefaultAsync();
}
public async Task<IEnumerable<RepoCompanySelection>> FindByCollateralIdAsync(int collateralId)
{
return await _context.RepoCompanySelections.Where(repoCompanySelection => repoCompanySelection.CollateralId == collateralId).ToListAsync();
}
public async Task<IEnumerable<RepoCompanySelection>> 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<RepoCompanySelection> repoCompanySelections)
{
_context.RepoCompanySelections.UpdateRange(repoCompanySelections);
}
}
}