public ActionResult Edit(Content model, FormCollection form) { using (var context = new StructureContainer()) { var content = context.Content.First(c => c.Id == model.Id); TryUpdateModel(content, new[] { "Name", "Title", "TitleEng", "PageTitle", "PageTitleEng", "SortOrder", "SeoDescription", "SeoKeywords" }); content.Text = HttpUtility.HtmlDecode(form["Text"]); content.TextEng = HttpUtility.HtmlDecode(form["TextEng"]); context.SaveChanges(); return RedirectToAction("Index", "Home", new { id = content.Name, area = "" }); } }
public ActionResult Add(FormCollection form) { using (var context = new StructureContainer()) { var content = new Content { MainPage = false, IsGallery = false }; TryUpdateModel(content, new[] { "Name", "Title", "TitleEng", "PageTitle", "PageTitleEng", "SortOrder", "SeoDescription", "SeoKeywords" }); content.Text = HttpUtility.HtmlDecode(form["Text"]); content.TextEng = HttpUtility.HtmlDecode(form["TextEng"]); context.AddToContent(content); context.SaveChanges(); return RedirectToAction("Index", "Home", new { id = content.Name, area = "" }); } }
/// <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="titleEng">Initial value of the TitleEng property.</param> /// <param name="pageTitleEng">Initial value of the PageTitleEng property.</param> /// <param name="textEng">Initial value of the TextEng property.</param> public static Content CreateContent(global::System.Int32 id, global::System.String name, global::System.String title, global::System.String pageTitle, global::System.String titleEng, global::System.String pageTitleEng, global::System.String textEng) { Content content = new Content(); content.Id = id; content.Name = name; content.Title = title; content.PageTitle = pageTitle; content.TitleEng = titleEng; content.PageTitleEng = pageTitleEng; content.TextEng = textEng; 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); }