public ActionResult Edit(int id, ArrestEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            var service = CreateArrestService();

            if (service.UpdateArrest(id, model))
            {
                TempData["SaveResult"] = "Arrest Updated";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Arrest not Updated");
            return(View(model));
        }
        public ActionResult Edit(int id)
        {
            var service = CreateArrestService();
            var detail  = service.GetArrestById(id);
            var model   = new ArrestEdit
            {
                ArrestDate    = DateTime.Now,
                StreetName    = detail.StreetName,
                ArrestCity    = detail.ArrestCity,
                ArrestCounty  = detail.ArrestCounty,
                ArrestState   = detail.ArrestState,
                ArrestZipcode = detail.ArrestZipcode,
                ArrestDesc    = detail.ArrestDesc,
                DefendantID   = detail.DefendantID,
                OfficerID     = detail.OfficerID
            };

            return(View(model));
        }
 public bool UpdateArrest(int id, ArrestEdit model)
 {
     using (var arr = new ApplicationDbContext())
     {
         var entity =
             arr
             .Arrests
             .Single(e => e.ArrestID == id);
         entity.ArrestDate    = model.ArrestDate;
         entity.StreetName    = model.StreetName;
         entity.ArrestCity    = model.ArrestCity;
         entity.ArrestCounty  = model.ArrestCounty;
         entity.ArrestState   = model.ArrestState;
         entity.ArrestZipcode = model.ArrestZipcode;
         entity.ArrestDesc    = model.ArrestDesc;
         entity.DefendantID   = model.DefendantID;
         entity.OfficerID     = model.OfficerID;
         return(arr.SaveChanges() == 1);
     }
 }