public bool UpdateProcedure(ProcedureEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Procedures .Single(e => e.ProcedureID == model.ProcedureId && e.OwnerID == _userId); entity.ProcedureName = model.ProcedureName; entity.ProcedureNote = model.ProcedureNote; entity.ProcedureRoute = model.ProcedureRoute; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id) { var service = CreateProcedureService(); var detail = service.GetProcedureById(id); var model = new ProcedureEdit { ProcedureId = detail.ProcedureId, ProcedureName = detail.ProcedureName, ProcedureNote = detail.ProcedureNote, ProcedureRoute = detail.ProcedureRoute }; return(View(model)); }
public ActionResult Edit(int id, ProcedureEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ProcedureId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateProcedureService(); if (service.UpdateProcedure(model)) { TempData["SaveResult"] = "Your procedure entry was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your procedure entry could not be updated."); return(View(model)); }