public ActionResult Edit(State state) { if (ModelState.IsValid && State.Update(state)) { return RedirectToAction("Index"); } return View(state); }
public static bool Create(State state) { bool result = true; try { db.States.AddObject(state); db.SaveChanges(); } catch (Exception) { result = false; } return result; }
public static bool Update(State state) { bool result = true; try { EntityDataModelContainer mc = new EntityDataModelContainer(); mc.States.Attach(state); mc.ObjectStateManager.ChangeObjectState(state, EntityState.Modified); mc.SaveChanges(); db.Refresh(System.Data.Objects.RefreshMode.StoreWins, state); } catch (Exception) { result = false; } return result; }
/// <summary> /// Deprecated Method for adding a new object to the States EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToStates(State state) { base.AddObject("States", state); }
/// <summary> /// Create a new State object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="updated_at">Initial value of the Updated_at property.</param> public static State CreateState(global::System.Int32 id, global::System.String name, global::System.DateTime updated_at) { State state = new State(); state.Id = id; state.Name = name; state.Updated_at = updated_at; return state; }