// GET: Edit public ActionResult Edit(int id) { var service = CreateScrumMasterService(); var detail = service.GetScrumMasterById(id); var model = new ScrumMasterEdit { ScrumMasterId = detail.ScrumMasterId, FirstName = detail.FirstName, LastName = detail.LastName }; return(View(model)); }
public bool UpdateScrumMaster(ScrumMasterEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .ScrumMasters .Single(e => e.ScrumMasterId == model.ScrumMasterId && e.OwnerId == _userId); entity.FirstName = model.FirstName; entity.LastName = model.LastName; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, ScrumMasterEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ScrumMasterId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateScrumMasterService(); if (service.UpdateScrumMaster(model)) { TempData["SaveResult"] = "Your scrum master was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Scrum master could not be updated."); return(View()); }