Esempio n. 1
0
 public ActionResult LastNews()
 {
     PostViewModel vm = new PostViewModel
     {
         Posts = _rep.Posts
             .OrderByDescending(x => x.CreatedAt)
             .ToList()
             .Take(3)
     };
     return PartialView(vm);
 }
Esempio n. 2
0
        //
        // GET: /Admin/Post/
        public ActionResult Index(int page = 1)
        {
            int pageSize = 15;
            PostViewModel vm = new PostViewModel
            {
                Posts = _rep.Posts
                    .OrderByDescending(x => x.CreatedAt)
                    .ToList()
                    .Skip((page - 1) * pageSize)
                    .Take(pageSize),

                PagingInfo = new PagingInfo
                {
                    TotalItems = _rep.Posts.Count(),
                    CurrentPage = page,
                    ItemsPerPage = pageSize

                }
            };
            return View(vm);
        }