Ejemplo n.º 1
0
        public override void ExecuteResult(ControllerContext context)
        {
            base.ExecuteResult(context);

            var viewModel = new CategoryCreatingViewModel();

            GetViewResult(viewModel).ExecuteResult(context);
        }
Ejemplo n.º 2
0
        public ActionResult Create(CategoryCreatingViewModel viewModel)
        {
            var category = PrepareCategory(viewModel, true);

            if (!_categoryCreatingPersistence.Validate(category))//check name, etc/
            {
                SetErrorMessage("Cannot create category with the same name");
            }

            if (_categoryCreatingPersistence.CreateCategory(category))
            {
                SetSucceedMessage("Save category successfully");
                //Refresh cach AllCategories
                AppCach.AllCategories.Add(category);
            }
            else
            {
                SetErrorMessage("Cannot create category");
            }

            return(RedirectToAction("Index", "Category"));
        }