public ActionResult Create(FormCollection collection) { try { using (var context = new LibraryContainer()) { var layout = new Layout(); TryUpdateModel(layout, new[] { "Name", "Title" }); context.AddToLayout(layout); context.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }
/// <summary> /// Create a new Layout 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> public static Layout CreateLayout(global::System.Int32 id, global::System.String name, global::System.String title) { Layout layout = new Layout(); layout.Id = id; layout.Name = name; layout.Title = title; return layout; }
/// <summary> /// Deprecated Method for adding a new object to the Layout EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToLayout(Layout layout) { base.AddObject("Layout", layout); }