using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Web;
|
|
namespace sbcLabSystem.Models.Backstage
|
{
|
public class PageNavigationViewModel
|
{
|
public PageNavigationViewModel() { }
|
public PageNavigationViewModel(int pageIndex, int pageItemCount, int maxItemCountInPage)
|
{
|
this.PageIndex = pageIndex;
|
this.PageItemCount = pageItemCount;
|
this.LastPageIndex = pageItemCount % maxItemCountInPage == 0 ? pageItemCount / maxItemCountInPage : (pageItemCount / maxItemCountInPage) + 1;
|
this.Pages = new List<int>();
|
this.Pages.Add(1);
|
for (int i = pageIndex - 4; i < pageIndex + 4; i++)
|
{
|
if (i < 2 || i > LastPageIndex - 1)
|
{
|
continue;
|
}
|
this.Pages.Add(i);
|
}
|
if (LastPageIndex > 1)
|
{
|
this.Pages.Add(LastPageIndex);
|
}
|
}
|
public int PageIndex { get; set; }
|
public int PageItemCount { get; set; }
|
public int LastPageIndex { get; set; }
|
public List<int> Pages { get; set; }
|
}
|
}
|