public ViewResult Category(string categoryName, int page = 0) { // Recover original categoryName categoryName = RoutingHelpers.RecoverOriginalUrlSegment(categoryName); // Create paged list of blogposts filtered by category var blogPostViewModel = new BlogPostViewModel { BlogPostPagedList = new StaticPagedList<BlogPost>(BlogPostRepo.GetQueryableBlogPostByCategory(categoryName).Skip(page * POSTS_PER_PAGE).Take(POSTS_PER_PAGE).ToList(), //Blog posts filtered by category name page, // page POSTS_PER_PAGE, BlogPostRepo.GetQueryableBlogPostByCategory(categoryName).Count()), // posts per page Title = "Blog posts with category: " + categoryName }; // Set message TempData[vinCMS.Infraestructure.Constants.VIEW_MESSAGE] = "Filtering blog posts by category: " + categoryName; // render view return View("Index", blogPostViewModel); }
/// <summary> /// Index Action Method. Renders a PagedList of BlogPosts /// </summary> /// <returns></returns> public ViewResult Index(int page = 0) { var blogPostViewModel = new BlogPostViewModel { BlogPostPagedList = new StaticPagedList<BlogPost>(BlogPostRepo.GetOrderedQueryableBlogPostWithIncludes().Skip(page*POSTS_PER_PAGE).Take(POSTS_PER_PAGE).ToList(), // IEnumerable<BlogPost> page, // Page POSTS_PER_PAGE, BlogPostRepo.GetOrderedQueryableBlogPostWithIncludes().Count()), // Number of posts per page Title = "Blog" }; return View(blogPostViewModel); }