26 lines
997 B
C#
26 lines
997 B
C#
using Distribution.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Distribution.Features.SupplierClaims;
|
|
|
|
public class SupplierClaimRepository(AppDBContext context) : ISupplierClaimRepository
|
|
{
|
|
public async Task<Models.SupplierClaim?> GetByIdAsync(Guid id) =>
|
|
await context.SupplierClaims
|
|
.Include(c => c.Items).ThenInclude(i => i.Item)
|
|
.FirstOrDefaultAsync(c => c.Id == id);
|
|
|
|
public async Task<List<Models.SupplierClaim>> GetByPurchaseOrderIdAsync(Guid purchaseOrderId) =>
|
|
await context.SupplierClaims
|
|
.Include(c => c.Items).ThenInclude(i => i.Item)
|
|
.Where(c => c.FK_PurchaseOrderId == purchaseOrderId && c.IsActive)
|
|
.OrderByDescending(c => c.CreatedAt)
|
|
.ToListAsync();
|
|
|
|
public async Task AddAsync(Models.SupplierClaim entity) =>
|
|
await context.SupplierClaims.AddAsync(entity);
|
|
|
|
public void Update(Models.SupplierClaim entity) =>
|
|
context.SupplierClaims.Update(entity);
|
|
}
|