public EmployeeEditDirectReports ( |
||
newItem | ||
return |
public ActionResult EditDirectReports(int?id, EmployeeEditDirectReports newItem) { // Validate the input if (!ModelState.IsValid) { // Our "version 1" approach is to display the "edit form" again return(RedirectToAction("editdirectreports", new { id = newItem.EmployeeId })); } if (id.GetValueOrDefault() != newItem.EmployeeId) { // This appears to be data tampering, so redirect the user away return(RedirectToAction("index")); } // Attempt to do the update var editedItem = m.EmployeeEditDirectReports(newItem); if (editedItem == null) { // There was a problem updating the object // Our "version 1" approach is to display the "edit form" again return(RedirectToAction("EditDirectReports", new { id = newItem.EmployeeId })); } else { // Show the details view, which will have the updated data return(RedirectToAction("Details", new { id = newItem.EmployeeId })); } }