예제 #1
0
        public void IsNextPageAvailable_WhenGivenZeroValuesAsArguments_ThenConditionReturnsFalse()
        {
            var expected = false;

            var actual = _pagionator.IsNextPageAvailable(0, 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));
        }