I am new to webapi and I am stuck with deserializing the json to the respective Child model
This is my model structure:
public abstract class FiscalInformation
{
int amount { get; set; }
int vat { get; set; }
}
public class GermanFiscal : FiscalInformation
{
string germancity { get; set; }``
string germanspecs { get; set; }
}
public class FrenchFiscal : FiscalInformation
{
string frenchcity { get; set; }
string frenchspecs { get; set; }
}
and this is my webapi controller:
[HttpPost]
[Route("api/fiscalinformation")]
public IHttpActionResult fiscalinformationupdate([FromBody] FiscalInformation fiscalInformation)
{
//fiscal information can be of type germanfiscal or of frenchfiscalinformation
//do something with the respective child model
return Ok();
}
if it is going to be a single property inside the model then i would have added
[JsonProperty(TypeNameHandling = TypeNameHandling.Auto)]
and I dont want to setup TypeNameHandling at global level too..
whenever the child object is posted from angular the fiscalinformation object comes as null
Please help me..