93f2f1bd3b
Major refactor replacing Sale/Order with ShopPO → Invoice → LoadingSheet flow. Removed legacy Sale/Order models and features; introduced ShopPO, ShopPOItem, Invoice, LoadingSheetOrder, and SysConfig models. Updated related entities, enums, repositories, and controllers. Added new migrations for schema changes and system config. Overhauled business logic and DI registrations. Updated documentation with migration plan.
36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using Distribution.Data;
|
|
using Distribution.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Distribution.Features.Payment;
|
|
|
|
public class PaymentRepository(AppDBContext context) : IPaymentRepository
|
|
{
|
|
public async Task<Models.Payment?> GetByIdAsync(Guid id) =>
|
|
await context.Payments.FirstOrDefaultAsync(p => p.Id == id && p.IsActive);
|
|
|
|
public async Task<List<Models.Payment>> GetAllAsync(Guid? invoiceId, int page, int pageSize) =>
|
|
await context.Payments
|
|
.Where(p => p.IsActive && (invoiceId == null || p.FK_InvoiceId == invoiceId))
|
|
.OrderByDescending(p => p.CollectedAt)
|
|
.Skip((page - 1) * pageSize)
|
|
.Take(pageSize)
|
|
.ToListAsync();
|
|
|
|
public async Task<int> GetCountAsync(Guid? invoiceId) =>
|
|
await context.Payments
|
|
.CountAsync(p => p.IsActive && (invoiceId == null || p.FK_InvoiceId == invoiceId));
|
|
|
|
public async Task<List<Models.Payment>> GetByInvoiceIdAsync(Guid invoiceId) =>
|
|
await context.Payments
|
|
.Where(p => p.FK_InvoiceId == invoiceId && p.IsActive)
|
|
.OrderBy(p => p.CollectedAt)
|
|
.ToListAsync();
|
|
|
|
public async Task AddAsync(Models.Payment payment) =>
|
|
await context.Payments.AddAsync(payment);
|
|
|
|
public void Update(Models.Payment payment) =>
|
|
context.Payments.Update(payment);
|
|
}
|