namespace API.Helpers;
#nullable enable
///
/// User params should be used together with [FromQuery] to add optional pagination to endpoint. If no pagination params are
/// provided, the default (int.MaxValue) will be used. When adding pagination to an endpoint, ensure the UI sets the correct
/// query params.
///
/// [FromQuery] always assigns the object, it'll never return null
public class UserParams
{
private const int MaxPageSize = int.MaxValue;
public int PageNumber { get; init; } = 1;
private readonly int _pageSize = MaxPageSize;
///
/// If set to 0, will set as MaxInt
///
public int PageSize
{
get => _pageSize;
init => _pageSize = (value == 0) ? MaxPageSize : value;
}
public static readonly UserParams Default = new()
{
PageSize = 20,
PageNumber = 1,
};
}