Esempio n. 1
0
        public ActionResult Edit(int id)
        {
            var service = CreateStateAttorneyService();
            var detail  = service.GetStateAttorneysById(id);
            var model   = new StateAttorneyEdit
            {
                FirstName = detail.FirstName,
                LastName  = detail.LastName
            };

            return(View(model));
        }
 public bool UpdateStateAttorney(int id, StateAttorneyEdit model)
 {
     using (var sat = new ApplicationDbContext())
     {
         var entity =
             sat
             .StateAttorneys
             .Single(e => e.StateAttorneyID == id);
         entity.FirstName = model.FirstName;
         entity.LastName  = model.LastName;
         return(sat.SaveChanges() == 1);
     }
 }
Esempio n. 3
0
        public ActionResult Edit(int id, StateAttorneyEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            var service = CreateStateAttorneyService();

            if (service.UpdateStateAttorney(id, model))
            {
                TempData["SaveResult"] = "State Attorney Updated";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "State Attorney not Updated");
            return(View(model));
        }