Ejemplo n.º 1
0
        public ActionResult BlogByCategoryID(int CategoryID, int Page)
        {
            var ops = new FITlosophiOperations();
            var blogVM = new BlogViewModel();
            var posts = ops.GetAllPostsByCategory(CategoryID);

            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/BlogByCategoryID?CategoryID=" + CategoryID + "&Page=" + (Page + 1);
            }

            if (Page > 1)
            {
                blogVM.NewUrl = "/Home/BlogByCategoryID?CategoryID=" + CategoryID + "&Page=" + (Page - 1);
            }

            return View("Index", blogVM);
        }
Ejemplo n.º 2
0
        public List<Category> Get()
        {
            var read = new FITlosophiOperations();

            return read.GetAllCategories();
        }
Ejemplo n.º 3
0
        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);
        }