Esempio n. 1
0
        public void Items_CountIs4PageSizeIs2_ThereAre2Items()
        {
            var pagerModel = new PagerModel {ItemCount = 4, PageSize = 2};

            var items = pagerModel.Items;

            Assert.Equal(2, items.Count());
        }
Esempio n. 2
0
        public void Items_CountIs11PageSizeIs3_ThirdItemIs3_7()
        {
            var pagerModel = new PagerModel{ItemCount = 11, PageSize = 3};

            var items = pagerModel.Items;

            var item = items.ElementAt(2);
            AssertPagerItem(item, 7, 3.ToString());
        }
Esempio n. 3
0
        public void Items_CountIs6PageSizeIs2_SecondItemIs2_3()
        {
            var pagerModel = new PagerModel{ItemCount = 6, PageSize = 2};

            var items = pagerModel.Items;

            var item = items.ElementAt(1);
            AssertPagerItem(item, 3, 2.ToString());
        }
Esempio n. 4
0
        public ActionResult Index(int startFrom = 1)
        {
            using (var blogEntities = new BlogEntities())
            {
                List<Post> posts;

                var filteredPosts = blogEntities.Posts
                    .FilterDrafts();
                var count = filteredPosts.Count();
                var pageSize = 10;
                posts = filteredPosts
                    .OrderByDescending(post => post.Posted)
                    .Skip(startFrom - 1)
                    .Take(pageSize)
                    .ToList();
                var pager = new PagerModel {ShowFrom = startFrom, ItemCount = count, PageSize = pageSize};
                var blogModel = new BlogModel{Posts = posts, PagerModel = pager};
                return View(blogModel);
            }
        }