public ActionResult Create(FormCollection form) { using (var context = new ModelContainer()) { var content = new Content(); TryUpdateModel(content, new[] { "Name", "Title", "PageTitle", "SortOrder", "MainPage", "SeoTitle", "SeoDescription", "SeoKeywords" }); content.Text = HttpUtility.HtmlDecode(form["Text"]); content.SeoText = HttpUtility.HtmlDecode(form["SeoText"]); context.AddToContent(content); context.SaveChanges(); return RedirectToAction("Index", "Home", new { Area = "", id = content.Name }); } }
/// <summary> /// Create a new Content object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="static">Initial value of the Static property.</param> /// <param name="mainPage">Initial value of the MainPage property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="pageTitle">Initial value of the PageTitle property.</param> public static Content CreateContent(global::System.Int32 id, global::System.String title, global::System.Boolean @static, global::System.Boolean mainPage, global::System.String name, global::System.String pageTitle) { Content content = new Content(); content.Id = id; content.Title = title; content.Static = @static; content.MainPage = mainPage; content.Name = name; content.PageTitle = pageTitle; return content; }
/// <summary> /// Deprecated Method for adding a new object to the Content EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToContent(Content content) { base.AddObject("Content", content); }