-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathTransactionData.cs
32 lines (27 loc) · 1.33 KB
/
TransactionData.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
namespace Cdr.Banking.Business.Data;
public partial class TransactionData
{
/// <summary>
/// Wires up the extensions.
/// </summary>
partial void TransactionDataCtor()
{
_getTransactionsOnQuery = GetTransactionsOnQuery;
}
/// <summary>
/// Perform the query filering for the GetTransactions.
/// </summary>
private IQueryable<Model.Transaction> GetTransactionsOnQuery(IQueryable<Model.Transaction> query, string? _, TransactionArgs? args)
{
if (args == null || args.IsInitial)
return query.OrderByDescending(x => x.TransactionDateTime);
var q = query.WhereWith(args.FromDate, x => x.TransactionDateTime >= args.FromDate);
q = q.WhereWith(args.ToDate, x => x.TransactionDateTime <= args.ToDate);
q = q.WhereWith(args.MinAmount, x => x.Amount >= args.MinAmount);
q = q.WhereWith(args.MaxAmount, x => x.Amount <= args.MaxAmount);
// The text filtering will perform a case-insensitive (based on uppercase) comparison on Description and Reference properties.
q = q.WhereWith(args.Text, x => x.Description!.ToUpper().Contains(args.Text!.ToUpper()) || x.Reference!.ToUpper().Contains(args.Text!.ToUpper()));
// Order by TransactionDateTime in descending order.
return q.OrderByDescending(x => x.TransactionDateTime);
}
}