public ActionResult Edit(int id) { BlogPost existingPost = _blogServices.GetBlogPost(id); List <Category> allCategories = _blogServices.GetAllCategories(); BlogPostVM model = WebServices.ConvertBlogPostToVeiwModel(existingPost, allCategories); return(View(model)); }
public ActionResult GetBlogPost(int id) { //TODO: check id is valid BlogPost existingPost = _blogServices.GetBlogPost(id); List <Category> allCategories = _blogServices.GetAllCategories(); var model = WebServices.ConvertBlogPostToVeiwModel(existingPost, allCategories); return(View(model)); }
public ActionResult Post() { BlogPost newPost = new BlogPost(); newPost.DateCreatedUTC = DateTime.UtcNow; newPost.UserId = User.Identity.GetUserId(); List <Category> allCategories = _blogServices.GetAllCategories(); var model = WebServices.ConvertBlogPostToVeiwModel(newPost, allCategories); return(View(model)); }
public ActionResult Post(BlogPostVM newBlogPost) { if (ModelState.IsValid) { BlogPost newPost = WebServices.ConvertBlogPostVMToBlogPost(newBlogPost); int blogId = _blogServices.AddNewBlogPost(newPost); _blogServices.AddCategoriesToBlogPost(blogId, newPost.AssignedCategories); List <Tag> newTags = _blogServices.AddCreatedTags(newPost.AssignedTags); _blogServices.AddTagsToBlog(blogId, newTags); return(RedirectToAction("AdminPanel", "Admin")); } List <Category> allCategories = _blogServices.GetAllCategories(); var model = WebServices.ConvertBlogPostToVeiwModel(newBlogPost.BlogPost, allCategories); return(View(model)); }