Exemple #1
0
        public ActionResult Create([Bind(Exclude = "Category.Name")] ArticleViewModel model)
        {
            try
            {
                ModelState.Remove("Category.Name");
                if (ModelState.IsValid)
                {
                    var article = ArticleFactory.CreateArticleFromViewModel(model, KBVaultHelperFunctions.UserAsKbUser(User).Id);
                    var id      = ArticleRepository.Add(article, model.Tags);
                    if (article.IsDraft == 0)
                    {
                        KbVaultLuceneHelper.AddArticleToIndex(article);
                    }

                    ShowOperationMessage(UIResources.ArticleCreatePageCreateSuccessMessage);
                    return(RedirectToAction("Edit", "Article", new { id = article.Id }));
                }

                return(View(model));
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                ModelState.AddModelError("Exception", ex.Message);
                return(View(model));
            }
        }