I need to create an end point, but this endpoint can have multiple types of input, the form itself can change based on configs, so i was trying to create at least 2 objects as possible inputs.
Something like:
public class ParticipationsController : ApiController
{
public HttpResponseMessage Post([FromBody]Models.SimpleParticipationModel sModel, [FromBody]Models.CompleteParticipationModel cModel)
{
if (!ModelState.IsValid) // this might not be this way here
{
return Request.CreateResponse(HttpStatusCode.BadRequest);
}
return Request.CreateResponse(HttpStatusCode.OK, "Ok");
}
My point is to avoid having multiple endpoints and change a lot of renderization in the page.
My objects contain DataAnotations to obey certain rules such as "Required" and "Range 0-X".
I also didn't what to have an object with all the properties, and only fulfill some of them.
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire