public ActionResult EditPost([Bind(Include = "ID,Title,Description,Priority,DateCreated,Owner,Status")] TicketDetailViewModel incomingTicket) { // ensure the model state is valid before updating the model if (ModelState.IsValid) { TicketHelper ticketHelper = new TicketHelper(c_repository); // fetch ticket to update, as we'll then update that ticket and pass it back to the business logic layer to save // although it might be more appropriate to hand off this work to the business logic layer? // the best solution to this is to change the code so that the incomingTicket can be mapped to a new ticket instance and then overwrite the entity in the DB in one call // therefore there would be no need to load the existing ticket in the DB and modify its properties Ticket ticketToUpdate = ticketHelper.RetrieveTicket(incomingTicket.ID); if (ticketToUpdate != null) { // map the updatable properties supplied back via parameter to the loaded Ticket // (this mapping could probably be done more elegantly, perhaps with AutoMapper) ticketToUpdate.Description = incomingTicket.Description; ticketToUpdate.Priority = incomingTicket.Priority; ticketToUpdate.Status = incomingTicket.Status; ticketToUpdate.Title = incomingTicket.Title; // try and update the ticket, did it go ok? if (ticketHelper.DoUpdateTicket(ticketToUpdate)) { // ticket updated succesfully - insert info message into TempData so that message can be shown on tickets list view this.TempData["Success"] = "Ticket updated succesfully."; // return the ticket that was updated to the view return(View(incomingTicket)); } else { // add model error to model state as we were unable to update the ticket // this will display a message in the ValidationSummary label within the Edit view ModelState.AddModelError("", "Unable to update the ticket at this time. Please try again."); // return view return(View(incomingTicket)); } } else { return(new HttpNotFoundResult("The ticket could not be updated, because the ticket could not be found.")); } } else { // model wasn't valid, reload same view return(View(incomingTicket)); } }