Пример #1
0
        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");
        }
Пример #2
0
        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");
        }
Пример #3
0
        public ActionResult Index()
        {
            State model = new State();

            return View(model);
        }