public ActionResult AddSubmenu(int parentId, FormCollection form) { using (var context = new ContentStorage()) { var parentContent = context.Content.Where(c => c.Id == parentId).First(); var content = new Content(); TryUpdateModel(content, new[] { "Name", "ContentModel", "Title", "MenuTitle", "PageTitle", "SortOrder", "SeoDescription", "SeoKeywords", //"ContentType", "ContentLevel", "PlaceKind" }); content.Text = HttpUtility.HtmlDecode(form["Text"]); content.WeatherScript = HttpUtility.HtmlDecode(form["WeatherScript"]); content.Parent = parentContent; context.AddToContent(content); context.SaveChanges(); if (content.PlaceKind > 0) return RedirectToAction("Index", "Place", new { id = content.Name, area = "" }); return RedirectToAction("Index", "Home", new { id = content.Name, area = "" }); } }
private void GetPlacesMap(Content content, ContentStorage context, List<MenuItem> map) { if (content.Parent != null) { var parentId = content.Parent.Id; content = context.Content.Include("Parent").First(c => c.Id == parentId); map.Add(new MenuItem { Name = content.Name, Title = content.Title, SortOrder = (int)content.ContentLevel }); GetPlacesMap(content, context, map); } }
private List<MenuItem> FillPlacesMap(Content content, ContentStorage context) { var map = new List<MenuItem> { new MenuItem { Name = content.Name, Title = content.Title, SortOrder = (int) content.ContentLevel } }; GetPlacesMap(content, context, map); return map; }
/// <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="contentLevel">Initial value of the ContentLevel property.</param> /// <param name="contentType">Initial value of the ContentType property.</param> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="sortOrder">Initial value of the SortOrder property.</param> /// <param name="placeKind">Initial value of the PlaceKind property.</param> public static Content CreateContent(global::System.Int64 contentLevel, global::System.Int64 contentType, global::System.Int64 id, global::System.String name, global::System.Int32 sortOrder, global::System.Int32 placeKind) { Content content = new Content(); content.ContentLevel = contentLevel; content.ContentType = contentType; content.Id = id; content.Name = name; content.SortOrder = sortOrder; content.PlaceKind = placeKind; return content; }
public ActionResult AddRegion(FormCollection form, int placeKind) { using (var context = new ContentStorage()) { var content = new Content { PlaceKind = placeKind, ContentLevel = 1 }; TryUpdateModel(content, new[]{ "Name", "Title", "MenuTitle", "PageTitle", "SortOrder", "SeoDescription", "SeoKeywords" }); content.Text = HttpUtility.HtmlDecode(form["Text"]); context.AddToContent(content); context.SaveChanges(); return RedirectToAction("Index", "Home", new { id = content.Name, area = "" }); } }