Skip to content

Commit 5407b40

Browse files
committed
[GEN-1863] add filtering parameters to wallet withdrawal request pagination
Added optional filtering parameters (status, walletId, userId, fromDate, toDate) to GetPaginatedAsync method in IWalletWithdrawalRequestRepository interface and implementation to enable filtered retrieval of wallet withdrawal requests. stack-info: PR: #481, branch: Jossec101/stack/14
1 parent d497a22 commit 5407b40

3 files changed

Lines changed: 167 additions & 114 deletions

File tree

src/Data/Repositories/Interfaces/IWalletWithdrawalRequestRepository.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ public interface IWalletWithdrawalRequestRepository : IBitcoinRequestRepository
3030

3131
Task<List<WalletWithdrawalRequest>> GetAll();
3232

33-
Task<(List<WalletWithdrawalRequest> Requests, int TotalCount)> GetPaginatedAsync(int pageNumber, int pageSize, IEnumerable<int>? excludedRequestIds = null);
33+
Task<(List<WalletWithdrawalRequest> Requests, int TotalCount)> GetPaginatedAsync(
34+
int pageNumber,
35+
int pageSize,
36+
IEnumerable<int>? excludedRequestIds = null,
37+
WalletWithdrawalRequestStatus? status = null,
38+
int? walletId = null,
39+
string? userId = null,
40+
DateTimeOffset? fromDate = null,
41+
DateTimeOffset? toDate = null);
3442

3543
Task<List<WalletWithdrawalRequest>> GetUnsignedPendingRequestsByUser(string userId);
3644

src/Data/Repositories/WalletWithdrawalRequestRepository.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,15 @@ public async Task<List<WalletWithdrawalRequest>> GetAll()
100100
.ToListAsync();
101101
}
102102

103-
public async Task<(List<WalletWithdrawalRequest> Requests, int TotalCount)> GetPaginatedAsync(int pageNumber, int pageSize, IEnumerable<int>? excludedRequestIds = null)
103+
public async Task<(List<WalletWithdrawalRequest> Requests, int TotalCount)> GetPaginatedAsync(
104+
int pageNumber,
105+
int pageSize,
106+
IEnumerable<int>? excludedRequestIds = null,
107+
WalletWithdrawalRequestStatus? status = null,
108+
int? walletId = null,
109+
string? userId = null,
110+
DateTimeOffset? fromDate = null,
111+
DateTimeOffset? toDate = null)
104112
{
105113
await using var applicationDbContext = await _dbContextFactory.CreateDbContextAsync();
106114

@@ -132,6 +140,21 @@ public async Task<List<WalletWithdrawalRequest>> GetAll()
132140
}
133141
}
134142

143+
if (status.HasValue)
144+
query = query.Where(x => x.Status == status.Value);
145+
146+
if (walletId.HasValue)
147+
query = query.Where(x => x.WalletId == walletId.Value);
148+
149+
if (!string.IsNullOrEmpty(userId))
150+
query = query.Where(x => x.UserRequestorId == userId);
151+
152+
if (fromDate.HasValue)
153+
query = query.Where(x => x.CreationDatetime >= fromDate.Value);
154+
155+
if (toDate.HasValue)
156+
query = query.Where(x => x.CreationDatetime <= toDate.Value);
157+
135158
query = query.OrderByDescending(x => x.CreationDatetime);
136159

137160
var totalCount = await query.CountAsync();

0 commit comments

Comments
 (0)