I need to pass two objects in the IActionResult method in Asp.net core. I try the following method but one object pass with the null values. what are the changes should I follow?
public IActionResult createService([FromBody] ArmSmServiceCreatorEntity CreateServiceDetail, [FromBody] ArmSmServiceAndSubServiceEntity createSSSDetails)
{
try
{
this.manager.BeginTransaction();
if (CreateServiceDetail == null)
{
return BadRequest("Service is null.");
}
this.manager.ArmSmServiceCreatorRepository.Add(CreateServiceDetail);
if (createSSSDetails == null)
{
return BadRequest("Service is null.");
}
this.manager.ArmSmServiceAndSubServiceRepository.Add(createSSSDetails);
this.manager.Commit();
return Ok("File was processed.");
}
catch (Exception ex)
{
this.manager.Rollback();
throw ex;
}
}
jsonwhich you are passing from client-side.