20 lines
662 B
C#
20 lines
662 B
C#
using Distribution.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Distribution.Features.Invoice;
|
|
|
|
public class InvoiceRepository(AppDBContext context) : IInvoiceRepository
|
|
{
|
|
public async Task<Models.Invoice?> GetByIdAsync(Guid id) =>
|
|
await context.Invoices.FindAsync(id);
|
|
|
|
public async Task<Models.Invoice?> GetByOrderIdAsync(Guid orderId) =>
|
|
await context.Invoices.FirstOrDefaultAsync(i => i.FK_OrderId == orderId && i.IsActive);
|
|
|
|
public async Task AddAsync(Models.Invoice entity) =>
|
|
await context.Invoices.AddAsync(entity);
|
|
|
|
public void Update(Models.Invoice entity) =>
|
|
context.Invoices.Update(entity);
|
|
}
|