public bool UpdateComplaint(ComplaintEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Complaints .Single(e => e.ComplaintID == model.ComplaintID); entity.InvestigatorID = model.InvestigatorID; entity.AgentID = model.AgentID; entity.InsurerID = model.InsurerID; entity.ConsumerID = model.ConsumerID; entity.ComplaintDesc = model.ComplaintDesc; entity.Resolved = model.Resolved; entity.DateSubmitted = model.DateSubmitted; entity.DateCompleted = model.DateCompleted; return(ctx.SaveChanges() == 1); } }
public ActionResult ComplaintEdit(int id) { var svc = new ComplaintService(); var detail = svc.GetComplaintByID(id); var model = new ComplaintEdit { ComplaintID = detail.ComplaintID, InvestigatorID = detail.InvestigatorID, AdminActionID = detail.AdminActionID, AgentID = detail.AgentID, InsurerID = detail.InsurerID, ConsumerID = detail.ConsumerID, ComplaintDesc = detail.ComplaintDesc, Resolved = detail.Resolved, DateSubmitted = detail.DateSubmitted, DateCompleted = detail.DateCompleted }; return(View(model)); }
public ActionResult ComplaintEdit(int id, ComplaintEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ComplaintID != id) { ModelState.AddModelError("", "ID Mismatch"); return(View(model)); } var svc = new ComplaintService(); if (svc.UpdateComplaint(model)) { TempData["SaveResult"] = "The Complaint was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "The Complaint could not be updated"); return(View(model)); }