public ActionResult DeleteState(State state) { if (state.StateID != 0) { var existingState = usaEntity.States.Find(state.StateID); usaEntity.States.Remove(existingState); } usaEntity.SaveChanges(); return Content("true"); }
public ActionResult SaveState(State state) { if (state.StateID == 0) usaEntity.States.Add(state); else { var existing = usaEntity.States.Find(state.StateID); if (!existing.Name.Equals(state.Name)) existing.Name = state.Name; if (existing.Abbreviation != null && !existing.Abbreviation.Equals(state.Abbreviation)) existing.Abbreviation = state.Abbreviation; } usaEntity.SaveChanges(); return Content("true"); }
public ActionResult Index() { State model = new State(); return View(model); }