Candor.PagingOptions.GetPagingByPage C# (CSharp) Method

GetPagingByPage() public static method

Creates a new paging options based on a nullable page and page size.
public static GetPagingByPage ( int page, int itemsPerPage ) : PagingOptions
page int Either null, or a 1 based page number (not page index)
itemsPerPage int Either null for the default, or the number of items for each page.
return PagingOptions
        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 };
        }