public ActionResult CreatePost(PostVM model, HttpPostedFileBase upload) { var mgr = new PostManager(); var catManager = new CategoryManager(); var post = new Post(); var filePath = "~/images/"; filePath = Server.MapPath(filePath); upload.SaveAs(filePath + upload.FileName); post.PostImageFileName = (upload.FileName); post.PostTitle = model.PostTitle; post.PostBody = model.PostBody; post.PostCategory = catManager.GetCategoryById(int.Parse(model.PostCategoryId)).Payload; post.PostTags = new List <Tag>() { new Tag() { TagName = "Test" } }; var response = mgr.AddPost(post); if (response.Success == false) { throw new Exception(); } model.ResetDropdown(); return(View(model)); }
public ActionResult CreatePost() { var model = new PostVM(); model.ResetDropdown(); return(View(model)); }