public bool CreateStateAttorney(StateAttorneyCreate model)
        {
            var entity = new StateAttorney()
            {
                StateAttorneyID = model.StateAttorneyID,
                FirstName       = model.FirstName,
                LastName        = model.LastName,
            };

            using (var sat = new ApplicationDbContext())
            {
                sat.StateAttorneys.Add(entity);
                return(sat.SaveChanges() == 1);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create(StateAttorneyCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateStateAttorneyService();

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