Exemplo n.º 1
0
        public PagingControls GetPagingControls(int totalNumberOfRecords
                                                , PagingStrategy pagingStrategy)
        {
            var controls = new PagingControls
            {
                PagesCount = GetPagesCount(totalNumberOfRecords)
            };

            controls = GetPrevNext(controls, pagingStrategy);

            return(controls);
        }
Exemplo n.º 2
0
 private PagingControls GetPrevNext(PagingControls controls
                                    , PagingStrategy pagingStrategy)
 {
     if (_pageNumber == 1)  //first page state
     {
         if (_pageNumber == controls.PagesCount)
         {
             controls.NextPage = null;
         }
         else
         {
             controls.NextPage = _pageNumber + 1;
         }
         controls.PrevPage = null;
     }
     else if (_pageNumber == controls.PagesCount) //last page state
     {
         controls.NextPage = null;
         controls.PrevPage = _pageNumber - 1;
     }
     else if (_pageNumber > controls.PagesCount)
     {
         if (pagingStrategy == PagingStrategy.ResetPagingToFirst)
         {
             _pageNumber = 1;
             return(GetPrevNext(new PagingControls
             {
                 PagesCount = controls.PagesCount
             }, PagingStrategy.ReturnNull));
         }
         else
         {
             return(null);
         }
     }
     else
     {
         controls.NextPage = _pageNumber + 1;
         controls.PrevPage = _pageNumber - 1;
     }
     return(controls);
 }