31 lines
871 B
C#
31 lines
871 B
C#
using LiteCharms.Features.Shop.Notifications.Models;
|
|
|
|
namespace LiteCharms.Features.Notifications.Queries;
|
|
|
|
public class GetNotificationsQuery : IRequest<Result<Notification[]>>
|
|
{
|
|
public DateOnly From { get; set; }
|
|
|
|
public DateOnly To { get; set; }
|
|
|
|
public int MaxRecords { get; set; }
|
|
|
|
private GetNotificationsQuery(DateOnly from, DateOnly to, int maxRecords = 1000)
|
|
{
|
|
From = from;
|
|
To = to;
|
|
MaxRecords = maxRecords;
|
|
}
|
|
|
|
public static GetNotificationsQuery 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.", nameof(maxRecords));
|
|
|
|
return new(from, to, maxRecords);
|
|
}
|
|
}
|