public ActionResult Edit(int id) { var service = CreateVetCheckService(); var detail = service.GetVetCheckById(id); var model = new VetCheckEdit { VetCheckId = detail.VetCheckId, Injury = detail.Injury, IntakeNotes = detail.IntakeNotes, TreatmentPlan = detail.TreatmentPlan }; return(View(model)); }
public bool UpdateVetCheck(VetCheckEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .VetChecks .Single(e => e.VetCheckId == model.VetCheckId && e.EmployeeId == _userId); entity.VetCheckId = model.VetCheckId; entity.IntakeNotes = model.IntakeNotes; entity.Injury = model.Injury; entity.TreatmentPlan = model.TreatmentPlan; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, VetCheckEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.VetCheckId != id) { ModelState.AddModelError("", "The VetCheckId entered does not match."); return(View(model)); } var service = CreateVetCheckService(); if (service.UpdateVetCheck(model)) { TempData["SaveResult"] = "The information has been updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Unable to update."); return(View(model)); }