public ActionResult Edit(Element model) { using (var context = new ModelContainer()) { var element = context.Element.First(e => e.Id == model.Id); TryUpdateModel(element, new[] { "Title", "SortOrder" }); context.SaveChanges(); } return RedirectToAction("Index", "Home", new { Area = "", id="" }); }
public ActionResult Create(FormCollection form) { using (var context = new ModelContainer()) { var element = new Element(); TryUpdateModel(element, new[] { "Title", "SortOrder" }); context.AddToElement(element); context.SaveChanges(); } return RedirectToAction("Index", "Home", new { Area = "", id = "" }); }
/// <summary> /// Deprecated Method for adding a new object to the Element EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToElement(Element element) { base.AddObject("Element", element); }
/// <summary> /// Create a new Element object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="title">Initial value of the Title property.</param> public static Element CreateElement(global::System.Int32 id, global::System.String title) { Element element = new Element(); element.Id = id; element.Title = title; return element; }