Sube carpetas API, API.Tests, Application y Domain del Backend
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
namespace Application.DTOs.Abstract.Request;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the ordering request properties.
|
||||
/// </summary>
|
||||
public interface IOrderRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// The property name to sort by.
|
||||
/// </summary>
|
||||
string? OrderBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sort order. Default is Ascending.
|
||||
/// </summary>
|
||||
SortOrder? Order { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Application.DTOs.Abstract.Request;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the pagination request properties.
|
||||
/// </summary>
|
||||
public interface IPaginationRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// The page number for pagination. Default is 1.
|
||||
/// </summary>
|
||||
int PageNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The page size for pagination. Defaults to 100.
|
||||
/// </summary>
|
||||
int PageSize { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using Application.Utils.Constants.Pagination;
|
||||
|
||||
namespace Application.DTOs.Abstract.Request;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request for paginated and filtered data.
|
||||
/// </summary>
|
||||
public class PaginatedFilterRequest : IPaginationRequest, IOrderRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// The page number for pagination. Default is 1.
|
||||
/// </summary>
|
||||
public int PageNumber { get; set; } = 1;
|
||||
|
||||
private int _pageSize = PaginationDefaults.DefaultPageSize;
|
||||
|
||||
/// <summary>
|
||||
/// The page size for pagination; values outside 1-100 are silently clamped rather than rejected.
|
||||
/// </summary>
|
||||
public int PageSize
|
||||
{
|
||||
get => _pageSize;
|
||||
set => _pageSize = ClampPageSize(value);
|
||||
}
|
||||
|
||||
private static int ClampPageSize(int requestedPageSize)
|
||||
{
|
||||
if (requestedPageSize < 1)
|
||||
{
|
||||
return PaginationDefaults.DefaultPageSize;
|
||||
}
|
||||
|
||||
return requestedPageSize > PaginationDefaults.MaxPageSize
|
||||
? PaginationDefaults.MaxPageSize
|
||||
: requestedPageSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The property name to sort by.
|
||||
/// </summary>
|
||||
public string? OrderBy { get; set; } = "DateCreated";
|
||||
|
||||
/// <summary>
|
||||
/// The sort order. Default is Ascending.
|
||||
/// </summary>
|
||||
public SortOrder? Order { get; set; } = SortOrder.Ascending;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Application.DTOs.Abstract.Request;
|
||||
|
||||
/// <summary>
|
||||
/// Enum to specify the sort order.
|
||||
/// </summary>
|
||||
public enum SortOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Ascending order.
|
||||
/// </summary>
|
||||
[Display(Name = "asc")]
|
||||
Ascending,
|
||||
|
||||
/// <summary>
|
||||
/// Descending order.
|
||||
/// </summary>
|
||||
[Display(Name = "desc")]
|
||||
Descending
|
||||
}
|
||||
Reference in New Issue
Block a user