namespace GDNXFD.Alert.Config.Model
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
///
/// Pagination Manager class.
///
public class PaginationConfig
{
private PageItem pageSelected;
private int itemsCounted;
private int pageSize;
///
/// Constructor
///
/// Items counted.
/// Size of the page.
public PaginationConfig(int itemsCounted, int pageSize)
{
this.itemsCounted = itemsCounted;
this.pageSize = pageSize;
this.pageSelected = new PageItem((1).ToString(), true, true);
}
///
/// Number of pages.
///
public int NumberOfPages
{
get { return (int)Math.Ceiling((double)this.itemsCounted / this.pageSize); }
}
///
/// Page size.
///
public int PageSize
{
get { return this.pageSize; }
set { this.pageSize = value; }
}
///
/// Page selected.
///
public PageItem PageSelected
{
get { return this.pageSelected; }
set { this.pageSelected = value; }
}
///
/// Number of page selected.
///
public int NumberOfPageSelected
{
get { return int.Parse(this.pageSelected.Page); }
set { this.pageSelected.Page = value.ToString(); }
}
///
/// Items counted.
///
public int ItemsCounted
{
get { return this.itemsCounted; }
set
{
this.itemsCounted = value;
}
}
///
/// This property is true if user can go to the next page.
///
public bool CanGoNext
{
get { return NumberOfPageSelected < NumberOfPages; }
}
///
/// This property is true if user can go to the previous page.
///
public bool CanGoPrevious
{
get { return 1 < NumberOfPageSelected; }
}
}
}