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);
        }
        public ActionResult EditPost(Post post)
        {
            var update = new FITlosophiOperations();

            update.EditPost(post);

            return View("ManagePosts");
        }
        public ActionResult EditPost(int id)
        {
            var read = new FITlosophiOperations();

            var postToEdit = read.GetPostByID(id);

            return View(postToEdit);
        }
        public ActionResult EditPage(StaticPage page)
        {
            var update = new FITlosophiOperations();

            update.EditPage(page);

            return View("ManagePages");
        }
        public ActionResult EditPage(int id)
        {
            var read = new FITlosophiOperations();

            var pageToEdit = read.GetPageByID(id);

            return View(pageToEdit);
        }
        public void PublishPost(int PostID)
        {
            var post = new Post();
            post.PostID = PostID;

            var update = new FITlosophiOperations();

            update.PublishPost(post);
        }
        public List<Category> Get()
        {
            var read = new FITlosophiOperations();

            return read.GetAllCategories();
        }
        public ActionResult PostPost(Post post)
        {
            var create = new FITlosophiOperations();

            create.AddPost(post);

            if (User.IsInRole("Admin"))
            {
                return View("ManagePosts");
            }

            return RedirectToAction("Index", "Home");
        }
        public Post GetPostByID(int PostID)
        {
            var read = new FITlosophiOperations();

            return read.GetPostByID(PostID);
        }
        public void EditPost(Post Post)
        {
            var update = new FITlosophiOperations();

            update.EditPost(Post);
        }
        public List<HashTag> Get()
        {
            var read = new FITlosophiOperations();

            return read.GetAllTags();
        }
        public List<Post> GetPostByAmount(int amount)
        {
            var read = new FITlosophiOperations();

            return read.GetPostsByAmount(amount);
        }
 public ActionResult StaticPage(int staticPageID)
 {
     var ops = new FITlosophiOperations();
     var staticPage = ops.GetPageByID(staticPageID);
     return View(staticPage);
 }
        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 void Post(Category category)
        {
            var post = new FITlosophiOperations();

            post.AddNewCategory(category);
        }
        public List<Post> GetAllPostsByCategory(int categoryID)
        {
            var read = new FITlosophiOperations();

            return read.GetAllPostsByCategory(categoryID);
        }
 public void DeletePage(int StaticPageID)
 {
     var delete = new FITlosophiOperations();
     delete.DeletePage(StaticPageID);
 }
        public List<Post> GetPostsByTagID(int tagID)
        {
            var read = new FITlosophiOperations();

            return read.GetPostsByTagID(tagID);
        }
        public void EditPage(StaticPage StaticPage)
        {
            var update = new FITlosophiOperations();

               update.EditPage(StaticPage);
        }
 public void DeletePost(int PostID)
 {
     var delete = new FITlosophiOperations();
     delete.DeletePost(PostID);
 }
        public List<StaticPage> GetAllPageSummaries()
        {
            var read = new FITlosophiOperations();

            return read.GetAllPageSummaries();
        }
        public List<Post> GetAllPostSummaries()
        {
            var read = new FITlosophiOperations();

            return read.GetAllPostSummaries();
        }
        public StaticPage GetPageByID(int PageID)
        {
            var read = new FITlosophiOperations();

            return read.GetPageByID(PageID);
        }
        public void Post(Post post)
        {
            var create = new FITlosophiOperations();

            create.AddPost(post);
        }
        public void PublishPage(int StaticPageID)
        {
            var update = new FITlosophiOperations();

            update.PublishPage(StaticPageID);
        }
        public void PublishPostWithSchedule(Post Post)
        {
            var update = new FITlosophiOperations();

            update.PublishPost(Post);
        }
Beispiel #27
0
        public ActionResult PostPage(StaticPage page)
        {
            var create = new FITlosophiOperations();

            create.AddStaticPage(page);

            if (User.IsInRole("Admin"))
            {
                return View("ManagePages");
            }

            return RedirectToAction("Index", "Home");
        }