I have a controller post action that receives an IList<> as a parameter, and would like to iterate that list and TryUpdateModel for each item in the list. Like
[HttpPost]
public ActionResult SaveList(IList<Stuff> listOfStuff)
{
// Get existing list of Stuff objects
IList<Stuff> currentStuff = db.GetStuffList();
// iterate over list of Stuff
foreach (Stuff stuff in listOfStuff)
{
// I'd like to do something akin to this
TryUpdateModel(currentStuff[correspondingItem_to_stuff], stuff);
}
As you can see, I would like to be able to TryUpdateModel against each item in listOfStuff, but there is no direct way to make that call with the two Stuff objects. What is the best way of accomplishing this?
Thanks