Beispiel #1
0
        public ActionResult Create(FormCollection form, int? parentId)
        {
            var building = new Building
                             {
                                 Name = Utils.Transliterator.Transliterate(form["Name"])
                             };
            TryUpdateModel(building, new[] { "Title", "SortOrder", "SeoDescription", "SeoKeywords", "ContentType" });
            building.CategoryLevel = 1;
            building.Active = true;
            building.Text = HttpUtility.HtmlDecode(form["Text"]);

            if (parentId.HasValue)
            {
                var parent = _context.Building.First(c => c.Id == parentId);
                parent.Children.Add(building);
            }
            else
            {
                _context.AddToBuilding(building);
            }
            _context.SaveChanges();


            switch (form["ContentType"])
            {
                case "1": return RedirectToAction("Buildings", "Home", new { area = "" });
                case "2": return RedirectToAction("Products", "Home", new { area = "" });
                case "3": return RedirectToAction("Documents", "Home", new { area = "" });
                case "4": return RedirectToAction("WhereToBuy", "Home", new { area = "" });
                case "5": return RedirectToAction("About", "Home", new { area = "" });
            }
            return RedirectToAction("Buildings", "Home", new { area = "" });
        }
Beispiel #2
0
 public ActionResult Edit(Building model)
 {
     var building = _context.Building.First(t => t.Id == model.Id);
     building.Name = Utils.Transliterator.Transliterate(model.Name);
     building.Title = model.Title;
     building.SortOrder = model.SortOrder;
     building.Text = HttpUtility.HtmlDecode(model.Text);
     building.SeoDescription = model.SeoDescription;
     building.SeoKeywords = model.SeoKeywords;
     building.Active = model.Active;
     _context.SaveChanges();
     switch (model.ContentType)
     {
         case 1: return RedirectToAction("Buildings", "Home", new { area = "" });
         case 2: return RedirectToAction("Products", "Home", new { area = "" });
         case 3: return RedirectToAction("Documents", "Home", new { area = "" });
         case 4: return RedirectToAction("WhereToBuy", "Home", new { area = "" });
         case 5: return RedirectToAction("About", "Home", new { area = "" });
     }
     return RedirectToAction("Buildings", "Home", new { area = "" });
 }
Beispiel #3
0
 /// <summary>
 /// Create a new Building 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="sortOrder">Initial value of the SortOrder property.</param>
 /// <param name="active">Initial value of the Active property.</param>
 /// <param name="categoryLevel">Initial value of the CategoryLevel property.</param>
 /// <param name="contentType">Initial value of the ContentType property.</param>
 public static Building CreateBuilding(global::System.Int32 id, global::System.String name, global::System.String title, global::System.Int32 sortOrder, global::System.Boolean active, global::System.Int32 categoryLevel, global::System.Int32 contentType)
 {
     Building building = new Building();
     building.Id = id;
     building.Name = name;
     building.Title = title;
     building.SortOrder = sortOrder;
     building.Active = active;
     building.CategoryLevel = categoryLevel;
     building.ContentType = contentType;
     return building;
 }
Beispiel #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Building EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBuilding(Building building)
 {
     base.AddObject("Building", building);
 }