Esempio n. 1
0
        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));
        }