Files
ERP_Distribution/Distribution/Features/ReceivedCheque/ReceivedChequeRepository.cs
T
Kalana B. Thilakarathna 87c807c16c
CI/CD - ERP Distribution / Build & Deploy Backend (pull_request) Failing after 11m8s
CI/CD - ERP Distribution / Build & Deploy Frontend (pull_request) Failing after 14m49s
feat: add cheque books and received cheques management
- 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.
2026-10-19 16:09:05 +05:30

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);
}