public IActionResult Tag(string name, int page = 1, bool viewall = false) { int take = _config.GetValue <int>("SlickCMS:PostsPerPage", 10); if (viewall) { take = _config.GetValue <int>("SlickCMS:ViewAllCount", 1000); } int totalPosts = _postService.TotalTagPosts(name); int remainder = (totalPosts % take); int totalPages = (totalPosts - remainder) / take; if (remainder > 0) { totalPages++; } var posts = _postService.Tag(name, page, take); var postsModel = new Models.PostsModel { Name = name, Posts = posts, Pagination = new Models.PaginationModel { TotalPages = totalPages, CurrentPage = page, TotalPosts = totalPosts, Query = "" }, Type = Models.PostsModel.PageType.Tag }; return(View("Tag", postsModel)); }
public IActionResult Posts(int page = 1, bool viewall = false) { if (!IsLoggedIn()) { return(Redirect("/admin")); } int take = _config.GetValue <int>("SlickCMS:AdminPostsPerPage", 20); if (viewall) { take = _config.GetValue <int>("SlickCMS:ViewAllCount", 1000); } int totalPosts = _postService.TotalPostsForAdmin(); int remainder = (totalPosts % take); int totalPages = (totalPosts - remainder) / take; if (remainder > 0) { totalPages++; } var posts = _postService.GetForAdmin(page, take); var postsModel = new Models.PostsModel { Name = "Posts", Posts = posts, Pagination = new Models.PaginationModel { TotalPages = totalPages, CurrentPage = page, TotalPosts = totalPosts, Query = "" }, Type = Models.PostsModel.PageType.Post }; return(View(postsModel)); }
public IActionResult Search(string query = "", int page = 1, bool viewall = false) { query = HttpUtility.HtmlEncode(query); int take = _config.GetValue <int>("SlickCMS:PostsPerPage", 10); if (viewall) { take = _config.GetValue <int>("SlickCMS:ViewAllCount", 1000); } int totalSearchResults = _postService.TotalSearchResults(query); int remainder = (totalSearchResults % take); int totalPages = (totalSearchResults - remainder) / take; if (remainder > 0) { totalPages++; } var searchResults = _postService.Search(query, page, take); var postsModel = new Models.PostsModel { Name = "Search", Posts = searchResults, Pagination = new Models.PaginationModel { TotalPages = totalPages, CurrentPage = page, TotalPosts = totalSearchResults, Query = query }, Type = Models.PostsModel.PageType.Search }; return(View("Search", postsModel)); }