public ActionResult Edit(Content model) { using (var context = new ShopContainer()) { Content content = context.Content.First(c => c.Id == model.Id); TryUpdateModel(content, new[] {"Name","Title","SortOrder","SeoDescription","SeoKeywords"}); content.Text = HttpUtility.HtmlDecode(model.Text); context.SaveChanges(); return RedirectToAction("Index", "Home", new { area = "", id = content.Name }); } }
public ActionResult Create(FormCollection form) { using (var context = new ShopContainer()) { var content = new Content(); TryUpdateModel(content, new[] { "Name", "Title", "PageTitle", "SortOrder", "Published", "MainPage", "SeoText", "SeoDescription", "SeoKeywords" }); content.Text = HttpUtility.HtmlDecode(form["Text"]); context.AddToContent(content); context.SaveChanges(); return RedirectToAction("Index"); } }
/// <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); }
/// <summary> /// Create a new Content object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="pageTitle">Initial value of the PageTitle property.</param> /// <param name="sortOrder">Initial value of the SortOrder property.</param> /// <param name="published">Initial value of the Published property.</param> /// <param name="mainPage">Initial value of the MainPage property.</param> public static Content CreateContent(global::System.Int32 id, global::System.String name, global::System.String title, global::System.String pageTitle, global::System.Int32 sortOrder, global::System.Boolean published, global::System.Boolean mainPage) { Content content = new Content(); content.Id = id; content.Name = name; content.Title = title; content.PageTitle = pageTitle; content.SortOrder = sortOrder; content.Published = published; content.MainPage = mainPage; return content; }