public void PagingAndRepeater(int id)
        {
            var repos = new BirdRepository();
            IList<Bird> birds = repos.GetBirds();

            IPaginatedPage items =
                PaginationHelper.CreatePagination(
                    birds, // list
                    10, // number of items per page
                    id
                    );

            PropertyBag["items"] = items;
        }
Exemple #2
0
        public ActionResult PagingAndRepeater(int? id)
        {
            var pageNumber = id ?? 1;
            var pageSize = 10;

            var repos = new BirdRepository();
            var allBirds = repos.GetBirds();
            var showBirds = allBirds.Skip((pageNumber - 1)*pageSize).Take(pageSize);
            var birdCount = allBirds.Count();

            return View(new Page<Bird>
                        {
                            Items = showBirds,
                            ItemCount = birdCount,

                            CurrentPage = pageNumber,
                            PageCount = (birdCount + pageSize - 1)/pageSize,

                            FirstItemIndex = (pageNumber - 1)*pageSize
                        });
        }