I have a model class looks like ,
public string EmpID { get; set; }
public string Mobile { get; set; }
public string Email { get; set; }
public string OfficeAddress { get; set; }
public string City { get; set; }
public string State { get; set; }
But In my Api response i want to send based on condition , if condition 1 satisfy then send below response,
{
"EmpID":"1",
"Email":"abc@gmail.com"
}
if condition 2 satisfy then send below response,
{
"EmpID":"1",
"Mobile":"1234567890"
"Email":"abc@gmail.com"
}
else
{
//send full model class property
}
//Note : I used JsonIgnore property in model class. But its not work in my case. Is there any way to Ignore Property in controller or bussiness logic layer ?