Exemple #1
0
        public ActionResult Blog(int Page)
        {
            var ops    = new FITlosophiOperations();
            var blogVM = new BlogViewModel();
            var posts  = ops.GetPostsByAmount(1000);

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

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

            return(View("Index", blogVM));
        }
Exemple #2
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));
        }
        public List <Post> GetPostByAmount(int amount)
        {
            var read = new FITlosophiOperations();

            return(read.GetPostsByAmount(amount));
        }