public ActionResult Create(FormCollection form) { try { using (var context = new CatalogueContainer()) { var article = new Article(); TryUpdateModel(article, new[] { "Title", "Date" }); article.Text = HttpUtility.HtmlDecode(form["Text"]); context.AddToArticle(article); context.SaveChanges(); return RedirectToAction("Index", "Articles", new { area = "" }); } } catch { return View(); } }
/// <summary> /// Create a new Article object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="date">Initial value of the Date property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="text">Initial value of the Text property.</param> public static Article CreateArticle(global::System.Int32 id, global::System.DateTime date, global::System.String title, global::System.String text) { Article article = new Article(); article.Id = id; article.Date = date; article.Title = title; article.Text = text; return article; }
/// <summary> /// Deprecated Method for adding a new object to the Article EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToArticle(Article article) { base.AddObject("Article", article); }