public ActionResult EditSingleStaticPage(int id) { var ops = new BlogPostOperations(); StaticPage newStaticPage = ops.GetStaticPageByID(id); return(View("EditSingleStaticPage", newStaticPage)); }
//[Authorize(Roles = "PR")] 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? }
public ActionResult EditStaticPage(StaticPage editedStaticPage) { var ops = new BlogPostOperations(); ops.EditStaticPage(editedStaticPage); //what view should be returned? return(RedirectToAction("Index", "Home")); }
public ActionResult DeletePost(int id) { var ops = new BlogPostOperations(); ops.DeletePost(id); return(RedirectToAction("Index", "Home")); }
public ActionResult EditPost(BlogPost editedPost) { var ops = new BlogPostOperations(); ops.EditPost(editedPost); return(RedirectToAction("Index", "Home")); }
public ActionResult DisplayStaticPage(int id) { var ops = new BlogPostOperations(); var vm = new HomeIndexViewModel(); var newStaticPage = ops.GetStaticPageByID(id); return(View(newStaticPage)); }
public ActionResult ApprovePost(int id) { var ops = new BlogPostOperations(); ops.SetPostTo1(id); return(RedirectToAction("DisplayPostsWithStatus0")); }
public ActionResult EditPost(int id) { var ops = new BlogPostOperations(); var vm = new EditPostViewModel(ops.GetAllCategories()); vm.BlogPost = ops.GetPostByID(id).FirstOrDefault(); return(View(vm)); }
public ActionResult EditStaticPage() { //need a list of static pages var ops = new BlogPostOperations(); var vm = new HomeIndexViewModel(); vm.StaticPages = ops.GetAllStaticPages(); return(View(vm)); }
public ActionResult DisplayPostsWithStatus2() { var ops = new BlogPostOperations(); var vm = new HomeIndexViewModel(); vm.BlogPosts = ops.GetPostsWithStatus2(); vm.Categories = ops.GetAllCategories(); vm.StaticPages = ops.GetAllStaticPages(); return(View(vm)); }
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)); }
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); }
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 })); }
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)); }
public void ParseTagsTest() { var ops = new BlogPostOperations(); string body = "This is a #test of how well my #METHOD parses #Tags."; string tagList = "here, Are more#tags # to# TEST #now"; var result = ops.ParseTags(body, tagList); List <string> expected = new List <string> { "test", "METHOD", "Tags", "here", "Are", "more", "tags", "to", "TEST", "now" }; Assert.AreEqual(expected, result); }
public ActionResult AddBlogEntry(BlogViewModel vm /*, IEnumerable<HttpPostedFileBase> images*/) { var repo = RepositoryFactory.CreateRepository(); var ops = new BlogPostOperations(); var blog = new BlogEntry() { Title = vm.Title, Body = vm.Body, DateExpire = vm.ExpireDate, //Images = new List<Image>(), User = repo.GetUserbyAspId(User.Identity.GetUserId()), IsApproved = User.IsInRole("Admin") }; #region Commented-out, multi-image upload method //TODO: MULTI-IMAGE, EVENTUALLY //foreach (var img in images) //{ // if (img != null && img.ContentLength > 0 && img.ContentType.Contains("image")) // { // try // { // string path = Path.Combine(Server.MapPath("~/App_Data"), Path.GetFileName(img.FileName)); // img.SaveAs(path); // blog.Images.Add(new Image {ImgPath = path}); // } // catch (Exception ex) // { // ViewBag.Message = "ERROR:" + ex.Message.ToString(); // } // } //} #endregion var tags = ops.ParseTags(vm.Body, vm.TagInput); foreach (var tag in tags) { blog.Tags.Add(new Tag { Name = tag }); } repo.AddBlogEntry(blog); return(RedirectToAction("Index", "Admin")); }
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)); }
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")); }
public List <Tag> Get() { var ops = new BlogPostOperations(); return(ops.GetAllTags()); }
public List <Category> Get() { var ops = new BlogPostOperations(); return(ops.GetAllCategories()); }