using System.Collections.Generic;
using System.Linq;

namespace IRaCIS.Core.Infrastructure.Extention
{
    /// <summary>
    /// 分页信息输出  泛型
    /// </summary>
    public class PageOutput<T>
    {
        /// <summary>
        /// 当前页索引
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 每页的记录条数
        /// </summary>
        public int PageSize { get; set; }
        
        /// <summary>
        /// 数据总数
        /// </summary>
        public long TotalCount { get; set; } = 0;

        /// <summary>
        /// 数据
        /// </summary>
        public IList<T> CurrentPageData { get; set; }

        public PageOutput()
        {
        }

        public PageOutput(int pageIndex, int pageSize, long totalCount, IList<T> data)
        {
            PageIndex = pageIndex;
            PageSize = pageSize;
            TotalCount = totalCount;
            CurrentPageData = data;
        }

        public PageOutput(int pageIndex, int pageSize, IQueryable<T> list)
        {
            PageIndex = pageIndex;
            PageSize = pageSize;
            TotalCount = list.Count();
            CurrentPageData = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
        }

      
    }
}
