Exemplo n.º 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();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Create a new Article object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="published">Initial value of the Published property.</param>
 /// <param name="text">Initial value of the Text property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 public static Article CreateArticle(global::System.Int32 id, global::System.String name, global::System.DateTime date, global::System.Boolean published, global::System.String text, global::System.String title)
 {
     Article article = new Article();
     article.Id = id;
     article.Name = name;
     article.Date = date;
     article.Published = published;
     article.Text = text;
     article.Title = title;
     return article;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Article EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToArticle(Article article)
 {
     base.AddObject("Article", article);
 }