namespace adas_core.Domain.Models.Responses;

/// <summary>
/// Represents a generic response wrapper for paginated data, typically used to return a subset of items along with associated pagination metadata.
/// </summary>
/// <typeparam name="T">The type of the items contained in the paginated response.</typeparam>
public class PaginationResponse<T>
{
    public PaginationResponse(List<T> data, int pageNumber, int pageSize, long totalRecords)
    {
        PageNumber = pageNumber;
        PageSize = pageSize;
        Data = data;
        TotalRecords = totalRecords;
        var totalPages = TotalRecords / (double)PageSize;
        var roundedTotalPages = Convert.ToInt64(Math.Ceiling(totalPages));
        TotalPages = roundedTotalPages;
    }

    public int PageNumber { get; set; }
    public int PageSize { get; set; }

    public long TotalPages { get; set; }
    public long TotalRecords { get; set; }
    public List<T> Data { get; set; }
}