예제 #1
0
        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");
        }
예제 #2
0
        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);
        }