public ActionResult FollowUpEdit(int id, FollowUpEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.FollowUpID != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var userId = Guid.Parse(User.Identity.GetUserId()); var service = new FollowUpService(userId); if (service.UpdateFollowUp(model)) { TempData["SaveResult"] = "Your Follow-up was updated."; return(RedirectToAction("FollowUpIndex")); } ModelState.AddModelError("", "Your Follow-up could not be updated."); return(View(model)); }
public ActionResult FollowUpEdit(int id) { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new FollowUpService(userId); var detail = service.GetFollowUpById(id); var model = new FollowUpEdit { FollowUpID = detail.FollowUpID, ShortDescription = detail.ShortDescription, FollowUpStatusID = detail.FollowUpStatusID, Notes = detail.Notes, DueUtc = (DateTimeOffset)detail.DueUtc }; return(View(model)); }
public bool UpdateFollowUp(FollowUpEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .FollowUps .Single(e => e.FollowUpID == model.FollowUpID && e.OwnerId == _userId); entity.ShortDescription = model.ShortDescription; entity.FollowUpStatusID = model.FollowUpStatusID; entity.Notes = model.Notes; entity.ModifiedUtc = model.ModifiedUtc; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }