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