Files
Extrudex/backend/API/DTOs/PagedResponse.cs
cubecraft-agents[bot] 230c3b295d initial commit
2026-04-25 18:51:05 +00:00

30 lines
1.0 KiB
C#

namespace Extrudex.API.DTOs;
/// <summary>
/// Generic paginated response wrapper for list endpoints.
/// Provides pagination metadata alongside the result items.
/// </summary>
/// <typeparam name="T">The type of items in the page.</typeparam>
public class PagedResponse<T>
{
/// <summary>The items in the current page.</summary>
public IReadOnlyList<T> Items { get; set; } = [];
/// <summary>Total number of items across all pages.</summary>
public int TotalCount { get; set; }
/// <summary>Current page number (1-based).</summary>
public int PageNumber { get; set; }
/// <summary>Number of items per page.</summary>
public int PageSize { get; set; }
/// <summary>Total number of pages.</summary>
public int TotalPages => PageSize > 0 ? (int)Math.Ceiling(TotalCount / (double)PageSize) : 0;
/// <summary>Whether there is a next page.</summary>
public bool HasNextPage => PageNumber < TotalPages;
/// <summary>Whether there is a previous page.</summary>
public bool HasPreviousPage => PageNumber > 1;
}