Files
monorepo/LCU.API.Collections.RepoApi-old/LCU.Shared.Collections.RepoApiLib/Repositories/CollateralRepository.cs
T
2026-04-20 14:47:24 -05:00

44 lines
1.3 KiB
C#

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