Hi All,
I am creating on web API for client using complex Model. Structure of model i am giving below
Public Class Organization
{
public Int Id{get; set;}
public string Name {get; set;}
public string ?website { get; set; }
public IEnumerable<Location> get; set; }
public IEnumerable<Contact> get; set; }
}
public class Location
{
public Int Id{get; set;}
public string Name {get; set;}
}
public class Contact
{
public Int Id{get; set;}
public string Name {get; set;}
}
As you can see Organization is my main class inside that i am using location and contact classes as list. In foreach loop i am checking condition like below
if (OrgData.contact.Count() > 0)
{
}
But user not passing any location or contact information how i manage while retrieving data. The above condition will fail. These location and contact is not mandatory. And also possibility in valid json data. How can i check data is valid or not?