Beispiel #1
0
        public ActionResult Create(Article article)
        {
            if (ModelState.IsValid)
            {
                _dataContext.Articles.Add(article);
                _dataContext.SaveChanges();

                return RedirectToAction("Detail", new { article.Id });
            }

            var model = GetManageArticleEditViewModel(article);
            return View(model);
        }
Beispiel #2
0
        private ManageArticleEditViewModel GetManageArticleEditViewModel(Article article)
        {
            var model = new ManageArticleEditViewModel
            {
                Article = article,
                HostSiteItems = GetHostSiteListItems(_dataContext.HostSites.ToList()),
                CategoryItems = GetCategoryListItems(_dataContext.Categories.ToList())
            };

            return model;
        }