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
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Application.DTOs.Abstract.Response;
|
||||
|
||||
/// <summary>
|
||||
/// Base response class containing common properties for responses.
|
||||
/// </summary>
|
||||
public class BaseEntityResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The unique identifier of the entity.
|
||||
/// </summary>
|
||||
public required Guid Id { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Application.DTOs.Abstract.Response;
|
||||
|
||||
/// <summary>
|
||||
/// A page of results together with the metadata needed to fetch adjacent pages.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of item contained in the page.</typeparam>
|
||||
public class PaginatedResponse<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The items in the collection.
|
||||
/// </summary>
|
||||
public IEnumerable<T> Items { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// The current page number.
|
||||
/// </summary>
|
||||
public required int Page { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of items in a page.
|
||||
/// </summary>
|
||||
public required int PageSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The total number of items in the collection.
|
||||
/// </summary>
|
||||
public required int TotalCount { get; set; }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user