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 ActionResult BlogDetail(int postID) { var blogDetailVM = new BlogDetailViewModel(); var ops = new FITlosophiOperations(); blogDetailVM.UserSelectedPost = ops.GetPostByID(postID); blogDetailVM.Categories = ops.GetAllCategories(); var readMorePosts = ops.GetPostsByAmount(10); blogDetailVM.Posts = readMorePosts.Where(p => p.PostID != postID).ToList(); return(View(blogDetailVM)); }
public List <Category> Get() { var read = new FITlosophiOperations(); return(read.GetAllCategories()); }