public void GetNextPageIndex_WhenGivenZeroValueForCurrentPageArgument_ThenExpectedFirstPageIndexReturned()
        {
            var expected = 1;

            var actual = _pagionator.GetNextPageIndex(0);

            Assert.That(expected, Is.EqualTo(actual));
        }
Example #2
0
        public async Task <IActionResult> GetAll(int page = 1, string search = null)
        {
            if (!_authentication.IsAuthenticated(User))
            {
                return(RedirectToAction("SignIn", "Authentication"));
            }

            IEnumerable <Employee> employees = await _repository.BrowseAsync(search);

            int pageCount    = _paginator.GetPageCount(employees.Count());
            int previousPage = _paginator.GetPreviousPageIndex(page);
            int nextPage     = _paginator.GetNextPageIndex(page);

            ViewBag.PreviousPage    = previousPage;
            ViewBag.NextPage        = nextPage;
            ViewBag.HasPreviousPage = _paginator.IsPreviousPageAvailable(previousPage);
            ViewBag.HasNextPage     = _paginator.IsNextPageAvailable(nextPage, pageCount);

            employees = employees
                        .Skip(_paginator.PageSize * (page - 1))
                        .Take(_paginator.PageSize)
                        .ToList();

            return(View("Browse", employees));
        }