using System;
using Quadarax.Foundation.Core.Data.Interface;

namespace Quadarax.Foundation.Core.Data
{
    public class Paging : IPaging
    {
        #region *** Properties ***
        /// <summary>
        /// Zero based index
        /// </summary>
        public int Page { get; }
        /// <summary>
        /// Number of items per page
        /// </summary>
        public int PageSize { get; }
        /// <summary>
        /// Defines if paging is disabled
        /// </summary>
        public bool IsDisabled { get;  }
        #endregion

        #region *** Constructors ***
        public Paging(int page, int pageSize)
        {
            IsDisabled = pageSize == 0;

            Page = page;
            PageSize = pageSize;
        }

        public Paging()
        {
            IsDisabled = true;
        }

        public static Paging NoPaging()
        {
            return new Paging();
        }
        #endregion

        #region *** Overrides ***
        public override string ToString()
        {
            return $"Paging:IsDisabled={IsDisabled};Page={Page};PageSize={PageSize}";
        }
        #endregion
    }
}
