Beispiel #1
0
        public override void ExecuteResult(ControllerContext context)
        {
            base.ExecuteResult(context);

            var viewModel = new NewsCreatingViewModel();

            //viewModel.AllCategories = _categoryRepository.GetCategories().ToList(); //TODO: to be from global cach

            GetViewResult(viewModel).ExecuteResult(context);
        }
        public ActionResult Create(NewsCreatingViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                SetErrorMessage("Please, fill the fields signed with *");
                return(View(viewModel));
            }

            var article = PrepareArticle(viewModel, true);

            if (_newsCreatingPersistence.CreateNews(article))
            {
                SetSucceedMessage("Save news successfully");
                //Refresh AppCach.AllNews
                AppCach.AllNews.Add(article);
            }
            else
            {
                SetErrorMessage("Cannot create article\news");
            }

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