I am trying to get a controller to take json data from a post request and set how I wish them to be applied in the model. Example:
public string model1 {
public string name { get; set; }
public string value { get; set; }
}
public string model2 {
public string ident { get; set; }
public IEnumerable<model1> model { get; set; }
}
I want model1 to contain the key, value of the properties in the json object. For example { ident: "moo", model: { fish: "sticks" } }
would produce model2 with ident: moo and ref model1 with an single entry containing name: fish and value: sticks.
I could easily do it in the controller, I am kind of wondering if there was a way via web api 2 that would allow me to specify how I wanted that model handled so I did not have to replicate it in every controller when a model ref model1.
Thanks