Added support for notifications
This commit is contained in:
@@ -8,17 +8,23 @@ public class GetCustomersQuery : IRequest<Result<Customer[]>>
|
||||
|
||||
public DateOnly To { get; set; }
|
||||
|
||||
private GetCustomersQuery(DateOnly from, DateOnly to)
|
||||
public int MaxRecords { get; set; }
|
||||
|
||||
private GetCustomersQuery(DateOnly from, DateOnly to, int maxRecords = 1000)
|
||||
{
|
||||
From = from;
|
||||
To = to;
|
||||
MaxRecords = maxRecords;
|
||||
}
|
||||
|
||||
public static GetCustomersQuery Create(DateOnly from, DateOnly to)
|
||||
public static GetCustomersQuery Create(DateOnly from, DateOnly to, int maxRecords = 1000)
|
||||
{
|
||||
if (from > to)
|
||||
throw new ArgumentException("From date cannot be greater than To date.");
|
||||
|
||||
return new(from, to);
|
||||
if(maxRecords <= 0)
|
||||
throw new ArgumentException("MaxRecords must be a positive integer.");
|
||||
|
||||
return new(from, to, maxRecords);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public class GetCustomersQueryHandler(IDbContextFactory<LeadGeneratorDbContext>
|
||||
var customers = await context.Customers.AsNoTracking()
|
||||
.OrderByDescending(o => o.CreatedAt)
|
||||
.Where(c => c.CreatedAt >= fromDate && c.CreatedAt <= toDate)
|
||||
.Take(request.MaxRecords)
|
||||
.ToArrayAsync(cancellationToken);
|
||||
|
||||
return customers?.Length > 0
|
||||
|
||||
Reference in New Issue
Block a user