initial commit
This commit is contained in:
30
backend/API/DTOs/PagedResponse.cs
Normal file
30
backend/API/DTOs/PagedResponse.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user