using System.Text.Json.Serialization;

namespace Indotalent.Shared.Models;

public class PagedList<T>
{
    public PagedList()
    {
        Value = new List<T>();
    }

    public List<T> Value { get; set; }
    public int Skip { get; set; }
    public int Top { get; set; }
    public int TotalPages { get; set; }
    public int Count { get; set; }

    [JsonConstructor]
    public PagedList(List<T> value, int count, int skip, int top, int totalPages)
    {
        Value = value;
        Count = count;
        Skip = skip;
        Top = top;
        TotalPages = totalPages;
    }

    public PagedList(List<T> value, int count, int skip, int top)
    {
        Value = value;
        Count = count;
        Skip = skip;
        Top = top;
        TotalPages = (int)Math.Ceiling(count / (double)top);
    }

    public bool HasPrevious => Skip > 0;
    public bool HasNext => (Skip + Top) < Count;
}