public ArticlesModel(ModelContainer context, string contentId, string articleId, bool loadContent=true) : base(context, contentId, articleId, loadContent) { Articles = _context.Article.ToList(); if(!string.IsNullOrEmpty(articleId)) { Article = _context.Article.First(a => a.Name == articleId); Title += " - " + Article.Title; } }
public ActionResult Create(FormCollection form) { using (var context = new ModelContainer()) { var article = new Article(); TryUpdateModel(article, new[] { "Title", "Name", "SortOrder" }); article.Text = HttpUtility.HtmlDecode(form["Text"]); context.AddToArticle(article); context.SaveChanges(); } return RedirectToAction("Index", "Articles", new { Area = "" }); }
/// <summary> /// Create a new Article object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="text">Initial value of the Text property.</param> /// <param name="name">Initial value of the Name property.</param> public static Article CreateArticle(global::System.Int32 id, global::System.String title, global::System.String text, global::System.String name) { Article article = new Article(); article.Id = id; article.Title = title; article.Text = text; article.Name = name; 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); }