public ActionResult BlogByTagID(int TagID, int Page) { var ops = new FITlosophiOperations(); var blogVM = new BlogViewModel(); var posts = ops.GetPostsByTagID(TagID); blogVM.Categories = ops.GetAllCategories(); blogVM.TotalPosts = posts.Count(); blogVM.Posts = posts.Skip((4 * Page) - 4).Take(10).ToList(); blogVM.Page = Page; // Calculate the total number of pages blogVM.TotalNumberOfPages = blogVM.TotalPosts / 4; if ((blogVM.TotalPosts % 4) > 0) { blogVM.TotalNumberOfPages++; } //Create paging url based on controller action if (Page < blogVM.TotalNumberOfPages) { blogVM.OlderUrl = "/Home/BlogByTagID?TagID=" + TagID + "&Page=" + (Page + 1); } if (Page > 1) { blogVM.NewUrl = "/Home/BlogByTagID?TagID=" + TagID + "&Page=" + (Page - 1); } return(View("Index", blogVM)); }
public List <Post> GetPostsByTagID(int tagID) { var read = new FITlosophiOperations(); return(read.GetPostsByTagID(tagID)); }