public ActionResult Index([FromUri] PaginationBindingModel model)
        {
            ViewBag.Title = "Home";
            var tweets = this.Data.Tweets.All()
                         .OrderByDescending(t => t.CreatedAt)
                         .Skip(model.StartPage * 10)
                         .Take(10);

            return(View(tweets));
        }
示例#2
0
        public ActionResult Index([FromUri] PaginationBindingModel model)
        {
            double tweetsCount = this.Data.Tweets.All().Count();
            int    pagesCount  = (int)Math.Ceiling(tweetsCount / 5);

            ViewBag.Title       = "Home";
            ViewBag.TweetsCount = tweetsCount;
            ViewBag.PagesCount  = pagesCount;

            var tweets = this.Data.Tweets.All()
                         .OrderByDescending(t => t.CreatedAt)
                         .Skip(model.StartPage * 5)
                         .Take(5)
                         .AsQueryable()
                         .Select(UserTweetViewModel.Create);

            return(View(tweets));
        }