public ActionResult Edit(BlogPostVM editedBlogPostVM) { if (ModelState.IsValid) { BlogPost postToBeProcessed = WebServices.ConvertBlogPostVMToBlogPost(editedBlogPostVM); _blogServices.ProcessEditedBlogPost(postToBeProcessed); return(RedirectToAction("AdminPanel", "Admin")); } return(View(editedBlogPostVM)); }
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)); }