Files
components/LiteCharms.Features/Shop/Orders/Queries/GetOrdersQuery.cs
T
2026-05-13 20:06:24 +02:00

30 lines
804 B
C#

using LiteCharms.Features.Shop.Orders.Models;
namespace LiteCharms.Features.Orders.Queries;
public class GetOrdersQuery : IRequest<Result<Order[]>>
{
public DateOnly From { get; set; }
public DateOnly To { get; set; }
public int MaxRecords { get; set; }
private GetOrdersQuery(DateOnly from, DateOnly to, int maxRecords = 1000)
{
From = from;
To = to;
MaxRecords = maxRecords;
}
public static GetOrdersQuery Create(DateOnly from, DateOnly to, int maxRecords = 1000)
{
if (from > to)
throw new ArgumentException("From date cannot be greater than To date.");
if(maxRecords <= 0)
throw new ArgumentException("MaxRecords must be a positive integer.");
return new(from, to, maxRecords);
}
}