87c807c16c
- Implemented ChequeBooksPage for viewing and filtering cheque books. - Added NewReceivedChequePage for recording received cheques. - Created ReceivedChequesPage for listing and managing received cheques. - Introduced API endpoints for bank accounts, cheque books, and received cheques. - Defined types for payments including bank accounts, cheque books, and received cheques.
35 lines
1.5 KiB
C#
35 lines
1.5 KiB
C#
using Distribution.Data;
|
|
using Distribution.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Distribution.Features.ReceivedCheque;
|
|
|
|
public class ReceivedChequeRepository(AppDBContext context) : IReceivedChequeRepository
|
|
{
|
|
public async Task<Models.ReceivedCheque?> GetByIdAsync(Guid id) =>
|
|
await context.ReceivedCheques.FirstOrDefaultAsync(c => c.Id == id);
|
|
|
|
public async Task<(List<Models.ReceivedCheque> Items, int TotalCount)> ListAsync(
|
|
int? companyId, int? branchId, ReceivedChequeStatus? status, ReceivedFromType? receivedFromType,
|
|
int page, int pageSize)
|
|
{
|
|
var query = context.ReceivedCheques.AsQueryable();
|
|
if (companyId is not null) query = query.Where(c => c.CompanyId == companyId);
|
|
if (branchId is not null) query = query.Where(c => c.BranchId == branchId);
|
|
if (status is not null) query = query.Where(c => c.Status == status);
|
|
if (receivedFromType is not null) query = query.Where(c => c.ReceivedFromType == receivedFromType);
|
|
|
|
var total = await query.CountAsync();
|
|
var items = await query
|
|
.OrderByDescending(c => c.ReceivedDate)
|
|
.Skip((page - 1) * pageSize)
|
|
.Take(pageSize)
|
|
.ToListAsync();
|
|
return (items, total);
|
|
}
|
|
|
|
public async Task AddAsync(Models.ReceivedCheque cheque) => await context.ReceivedCheques.AddAsync(cheque);
|
|
|
|
public void Update(Models.ReceivedCheque cheque) => context.ReceivedCheques.Update(cheque);
|
|
}
|