/// <summary>
/// Creates a new paging options based on a nullable page and page size.
/// </summary>
/// <param name="page">Either null, or a 1 based page number (not page index)</param>
/// <param name="itemsPerPage">Either null for the default, or the number of items for each page.</param>
/// <returns></returns>
public static PagingOptions GetPagingByPage(int?page, int?itemsPerPage)
{
if (!page.HasValue && !itemsPerPage.HasValue)
{
return(PagingOptions.GetDisabledPagingOptions());
}
if (!itemsPerPage.HasValue)
{
return new PagingOptions()
{
PageIndex = page.Value - 1
}
}
;
if (!page.HasValue)
{
return new PagingOptions()
{
PageIndex = 0, PageSize = itemsPerPage.Value
}
}
;
return(new PagingOptions()
{
PageIndex = page.Value - 1, PageSize = itemsPerPage.Value
});
}
#endregion Specialty
}
}