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); }
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); }
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); }
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); }