Add invoice repository
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user