public ActionResult Index(DraftPostVM model) { var blogPost = new BlogPost(); blogPost = model.NewPost; blogPost.PostContent = model.HtmlContent; if (model.NewPost.Status == null) { blogPost.Status = new Status() { StatusID = 1 }; } else { blogPost.Status.StatusID = model.NewPost.Status.StatusID; } var ops = OperationsFactory.CreateBlogPostOps(); var categoryOps = OperationsFactory.CreateCategoryOps(); ops.SaveBlogPost(blogPost); categoryOps.SaveBlogPostCategory(model.SelectedCategoryIds,blogPost); return RedirectToAction("Index","Home"); }
public ActionResult Index() { DraftPostVM model = new DraftPostVM() { NewPost = new BlogPost() { Status = new Status(), User = new User() }, SelectedCategoryIds = new List<int>() }; var categoryOps = OperationsFactory.CreateCategoryOps(); var hashOps = OperationsFactory.CreateHashtagOps(); var statusOps = OperationsFactory.CreateStatusOps(); var categoryList = categoryOps.ListAllCategories(); var hastagList = hashOps.ListAllHashtags(); var statusList = statusOps.ListAllStatuses(); model.GenerateHashtagsList(hastagList); model.GenerateCategoriesList(categoryList); model.GenerateStatusList(statusList); return View(model); }