// GET: PR public ActionResult PRDashboard() { _ops = new BlogOperations(); var vm = new PRVM(); vm.BlogPosts = _ops.GetAllBlogPosts().BlogPosts.OrderByDescending(p => p.TimeCreated).ToList(); return View(vm); }
public ActionResult Index() { _ops = new BlogOperations(); var vm = new HomeVM(); vm.BlogPosts = _ops.GetAllBlogPosts().BlogPosts.Where(p => p.Status == PageStatus.Approved).OrderByDescending(p => p.TimeCreated).ToList(); vm.BlogStats = _ops.GetBlogStats().BlogStats; vm.Categories = _ops.GetAllCategories().Categories; return View(vm); }
public ActionResult AllPosts(int id) { _ops = new BlogOperations(); var vM = new AllPostsVM(); var allPosts = _ops.GetAllBlogPosts().BlogPosts.Where(p => p.Status == PageStatus.Approved).OrderByDescending(p => p.TimeCreated).ToList(); vM.PostCount = allPosts.Count; vM.CurrentPage = id; vM.TotalPages = (int)Math.Ceiling((double)vM.PostCount/(double)5); if (id < vM.TotalPages) { for (int i = 5 * (id - 1); i < 5 * id; i++) { vM.BlogPosts.Add(allPosts[i]); } } else if (id == vM.TotalPages) { for (int i = 5 * (id - 1); i < vM.PostCount; i++) { vM.BlogPosts.Add(allPosts[i]); } } vM.Categories = _ops.GetAllCategories().Categories; return View("AllPosts", vM); }
public ActionResult ViewCategory(int id) { _ops = new BlogOperations(); var vM = new ViewCategoryVM(); vM.BlogPosts = _ops.GetAllBlogPosts().BlogPosts.Where(p => p.Category.CategoryId == id).OrderByDescending(p => p.TimeCreated).ToList(); vM.Categories = _ops.GetAllCategories().Categories; vM.CurrentCategory.CategoryId = id; vM.CurrentCategory.CategoryTitle = _ops.GetCategoryById(id).Category.CategoryTitle; return View("ViewCategory", vM); }
public ActionResult SearchPosts() { _ops = new BlogOperations(); var vM = new AllPostsVM(); vM.BlogPosts = _ops.GetAllBlogPosts() .BlogPosts.Where(p => p.Status == PageStatus.Approved) .OrderBy(p => p.BlogPostTitle) .ToList(); vM.Categories = _ops.GetAllCategories().Categories; return View("SearchPosts", vM); }