Retructured solution
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using LiteCharms.Features.Shop.CartPackages.Models;
|
||||
|
||||
namespace LiteCharms.Features.CartPackages.Queries;
|
||||
|
||||
public class GetPackagesQuery : IRequest<Result<Package[]>>
|
||||
{
|
||||
public DateOnly From { get; set; }
|
||||
|
||||
public DateOnly To { get; set; }
|
||||
|
||||
public int MaxRecords { get; set; }
|
||||
|
||||
public bool Active { get; set; }
|
||||
|
||||
private GetPackagesQuery(DateOnly from, DateOnly to, int maxRecords = 1000, bool active = true)
|
||||
{
|
||||
From = from;
|
||||
To = to;
|
||||
MaxRecords = maxRecords;
|
||||
Active = active;
|
||||
}
|
||||
|
||||
public static GetPackagesQuery Create(DateOnly from, DateOnly to, int maxRecords = 1000, bool active = true)
|
||||
{
|
||||
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, active);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user