Exemple #1
0
        public ActionResult Create(FormCollection form)
        {
            try
            {
                using (var context = new ShopContainer())
                {
                    var article = new Article { Date = DateTime.Now };
                    TryUpdateModel(article, new[]
                                                {
                                                    "Name", 
                                                    "Title", 
                                                    "Published", 
                                                    "SeoDescription", 
                                                    "SeoKeywords"
                                                });
                    article.Text = HttpUtility.HtmlDecode(form["Text"]);

                    context.AddToArticle(article);
                    context.SaveChanges();
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }