I have a React component that posts to an API controller like this:
onSubmit={async values => {
await new Promise(resolve => setTimeout(resolve, 500));
axios({
method: "POST",
url: "/educationalgames/api/acceptentry",
data: values
});
alert(JSON.stringify(values, null, 2));
}}
When I hit submit, I see the values it finds:
{
"eligiblePlayers": [],
"teamName": "FalconOne",
"teamEmail": "fc@coma.edu",
"trainer": "",
"department": "Physics",
"researchType": "Meta",
"numOfStudents": 50,
"currentState": true
}
The data above are properties from a mix of different models in my c# backend API.
teamName, teamEmail, and trainer belong to my team.cs model.
eligiblePlayers, department belong to the department.cs model.
researchType, numOfStudents, and currentState belong to my research.cs model.
My question is, I can't figure out how do I translate that data so that my API controller can read it and assign the proper values to the matching model properties.
So far I have this in my c# controller:
[HttpPost]
public async Task<ActionResult> AcceptEntry([FromBody] ???)
I'm kind of at a loss to handle this.
Is there a way?
Thanks!