Пример #1
0
 public ViewResult Category(string category, int p = 1)
 {
     var postsListViewModel = new PostsListViewModel
     {
         Posts = _repo.PostsForCategory(category)
             .Skip((p - 1) * PageSize)
             .Take(PageSize),
         PagingInfo = new PagingInfo
         {
             CurrentPage = p,
             ItemsPerPage = PageSize,
             TotalItems = _repo.TotalPostsForCategory(category)
         },
         CurrentCategory = category
     };
     return View(postsListViewModel);
 }
Пример #2
0
 public ViewResult Posts(int p = 1)
 {
     ViewBag.Title = "Latest on Blog";
     var postsListViewModel = new PostsListViewModel
     {
         Posts = _repo.GetPostedPosts()
             .Skip((p - 1) * PageSize)
             .Take(PageSize),
         PagingInfo = new PagingInfo
         {
             CurrentPage = p,
             ItemsPerPage = PageSize,
             TotalItems = _repo.TotalPosts()
         }
     };
     return View(postsListViewModel);
 }
Пример #3
0
 public ViewResult Search(string s, int p = 1)
 {
     var postsListViewModel = new PostsListViewModel
     {
         Posts = _repo.PostsForSearch(s)
             .Skip((p - 1) * PageSize)
             .Take(PageSize),
         PagingInfo = new PagingInfo
         {
             CurrentPage = p,
             ItemsPerPage = PageSize,
             TotalItems = _repo.TotalPostsForSearch(s)
         },
          CurrentSearch = s
     };
     return View(postsListViewModel);
 }
Пример #4
0
 public ViewResult Tag(string tag, int p = 1)
 {
     var postsListViewModel = new PostsListViewModel
     {
         Posts = _repo.PostsForTag(tag)
             .Skip((p - 1) * PageSize)
             .Take(PageSize),
         PagingInfo = new PagingInfo
         {
             CurrentPage = p,
             ItemsPerPage = PageSize,
             TotalItems = _repo.TotalPostForTag(tag)
         },
         CurrentTag = tag
     };
     return View(postsListViewModel);
 }