Пример #1
0
        public void GetPreviousPageIndex_WhenGivenZeroValueForCurrentPageArgument_ThenExpectedZeroReturned()
        {
            var expected = 0;

            var actual = _pagionator.GetPreviousPageIndex(0);

            Assert.That(expected, Is.EqualTo(actual));
        }
Пример #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));
        }