예제 #1
0
 // 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);
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }