public ActionResult FollowUpStatusEdit(int id, FollowUpStatusEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.FollowUpStatusTypeID != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var userId = Guid.Parse(User.Identity.GetUserId()); var service = new FollowUpStatusService(userId); if (service.UpdateFollowUpStatus(model)) { TempData["SaveResult"] = "Your Status Type was updated."; return(RedirectToAction("FollowUpStatusIndex")); } ModelState.AddModelError("", "Your Status Type could not be updated."); return(View(model)); }
public bool UpdateFollowUpStatus(FollowUpStatusEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .FollowUpStatusTypes .Single(e => e.FollowUpStatusTypeID == model.FollowUpStatusTypeID && e.OwnerId == _userId); entity.Status = model.Status; entity.Description = model.Description; return(ctx.SaveChanges() == 1); } }
public ActionResult FollowUpStatusEdit(int id) { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new FollowUpStatusService(userId); var detail = service.GetFollowUpStatusById(id); var model = new FollowUpStatusEdit { FollowUpStatusTypeID = detail.FollowUpStatusTypeID, Status = detail.Status, Description = detail.Description }; return(View(model)); }