Example #1
0
        public ActionResult ApprovePost(int id)
        {
            var ops = new BlogPostOperations();
            ops.SetPostTo1(id);

            return RedirectToAction("DisplayPostsWithStatus0");
        }
Example #2
0
        public ActionResult DeletePost(int id)
        {
            var ops = new BlogPostOperations();
            ops.DeletePost(id);

            return RedirectToAction("Index", "Home");
        }
Example #3
0
        public ActionResult DisplayStaticPage(int id)
        {
            var ops = new BlogPostOperations();
            var vm = new HomeIndexViewModel();
               var newStaticPage = ops.GetStaticPageByID(id);

            return View(newStaticPage);
        }
Example #4
0
        public ActionResult ListPostsByTag(int id)
        {
            var ops = new BlogPostOperations();
            var vm = new HomeIndexViewModel();
            vm.BlogPosts = ops.GetPostsByTagID(id);
            vm.Categories = ops.GetAllCategories();
            vm.StaticPages = ops.GetAllStaticPages();

            return View("Index", vm);
        }
Example #5
0
        public ActionResult AddUserComment(AddUserCommentViewModel vm)
        {
            var ops= new BlogPostOperations();
            var userComment = new UserComment();
            userComment.UserCommentContent = vm.UserCommentContent;
            userComment.UserCommentDate = DateTime.Parse(vm.UserCommentDate);
            userComment.UserCommentUserName = vm.UserCommentUserName;

            ops.AddNewUserComment(userComment, vm.PostID);

            return RedirectToAction("ListSinglePost", new {id= vm.PostID});
        }
Example #6
0
        public HttpResponseMessage Post(Category newCategory)
        {
            var ops = new BlogPostOperations();
            ops.AddCategory(newCategory);

            var response = Request.CreateResponse(HttpStatusCode.Created, newCategory);

            string uri = Url.Link("DefaultApi", new {id = newCategory.CategoryID});
            response.Headers.Location = new Uri(uri);

            return response;
        }
Example #7
0
        public ActionResult ListSinglePost(int id)
        {
            // Added a new view in order to view the whole post without the truncation from dotdotdot.
            // Also for viewing comments
            var ops = new BlogPostOperations();
            //var vm = new HomeIndexViewModel();
            var vm = new ListSinglePostViewModel();
            vm.BlogPost = ops.GetPostByID(id).FirstOrDefault();
            vm.Categories = ops.GetAllCategories();
            vm.StaticPages = ops.GetAllStaticPages();
            //vm.RouteID = ; can we use this to go back to the right routed page on the home index?

            return View(vm);
        }
Example #8
0
        public ActionResult Index(int id = 0)
        {
            var ops = new BlogPostOperations();
            var vm = new HomeIndexViewModel();
            //vm.BlogPosts = ops.GetBlogPosts();
            vm.Categories = ops.GetAllCategories();
            vm.StaticPages = ops.GetAllStaticPages();
            // paging
            var posts = ops.GetBlogPosts();
            vm.PostTotal = posts.Count;
            vm.RouteID = id;
            vm.BlogPosts = posts.Skip(id*5).Take(5).ToList();

            return View(vm);
        }
Example #9
0
        public ActionResult AddBlogPost(BlogPost blogPost)
        {
            var ops = new BlogPostOperations();
            if (User.IsInRole("Admin"))
            {
                // Admin add post, post goes to table with status of 1
                ops.AddNewBlogPost(blogPost);
                return RedirectToAction("Index", "Home");
            }
            if (User.IsInRole("PR"))
            {
                // PR add post, post goes to table with status of 0
                ops.PRAddNewBlogPost(blogPost);
                return RedirectToAction("Index", "Home");
            }

            // somehow a non-authenticated add. nothing goes to data. (necessary?)
            return RedirectToAction("Index", "Home");
        }
Example #10
0
 public List<Tag> Get()
 {
     var ops = new BlogPostOperations();
     return ops.GetAllTags();
 }
Example #11
0
 public List<Category> Get()
 {
     var ops = new BlogPostOperations();
     return ops.GetAllCategories();
 }
Example #12
0
        public ActionResult EditPost(BlogPost editedPost)
        {
            var ops = new BlogPostOperations();
            ops.EditPost(editedPost);

            return RedirectToAction("Index", "Home");
        }
Example #13
0
        public ActionResult EditPost(int id)
        {
            var ops = new BlogPostOperations();
            var vm = new EditPostViewModel(ops.GetAllCategories());
            vm.BlogPost = ops.GetPostByID(id).FirstOrDefault();

            return View(vm);
        }
Example #14
0
        public ActionResult EditSingleStaticPage(int id)
        {
            var ops = new BlogPostOperations();
               StaticPage newStaticPage = ops.GetStaticPageByID(id);

            return View("EditSingleStaticPage", newStaticPage);
        }
Example #15
0
        public ActionResult DisplayPostsWithStatus0()
        {
            var ops = new BlogPostOperations();
            var vm = new HomeIndexViewModel();
            vm.BlogPosts = ops.GetPostsWithStatus0();
            vm.Categories = ops.GetAllCategories();
            vm.StaticPages = ops.GetAllStaticPages();

            return View(vm);
        }
Example #16
0
        public ActionResult EditStaticPage()
        {
            //need a list of static pages
            var ops = new BlogPostOperations();
            var vm = new HomeIndexViewModel();
            vm.StaticPages = ops.GetAllStaticPages();

            return View(vm);
        }
Example #17
0
 public ActionResult EditStaticPage(StaticPage editedStaticPage)
 {
     var ops = new BlogPostOperations();
     ops.EditStaticPage(editedStaticPage);
     //what view should be returned?
     return RedirectToAction("Index", "Home");
 }
Example #18
0
 public ActionResult AddBlogPost()
 {
     var ops = new BlogPostOperations();
     var vm = new AddBlogPostViewModel(ops.GetAllCategories());
     return View(vm); // Author is currently being populated as the user identity email. Switch to username?
 }