Some sample code patched together. First the controller method:
public ActionResult ProcessModel()
{
ViewRolePermissionsModel newResponse = ProcessRoles(Request.Form);
}
and then the method to parse this into the model
private ViewRolePermissionsModel ProcessRoles(System.Collections.Specialized.NameValueCollection requestForm)
{
ViewRolePermissionsModel viewRolePermissionsModel = new ViewRolePermissionsModel();
String[] allKeys = requestForm.AllKeys;
foreach (String localKey in allKeys)
{
itemValue = requestForm.GetValues(localKey).FirstOrDefault();
// depending on the localKey either use this to add the value to the model or to build a list to be added later
}
}