I am calling several API's so I have a problem to group received data
For example:
- Api 1 is returning a list of objects and each object have different buildingId.
- That buildingId I need to use as an input for Api 2 which is returning list of objects (apartments) where each of the apartment have different apartmentId.
- Then I have to call Api 3 and use apartmentId as an input and I will receive a list of owner/s of the apartment.
Final result should be like
BuildingA
Apartment1
ApartmentOwner1
ApartmentOwner2
Apartment2
ApartmentOwner3
Apartment3
ApartmentOwner4
ApartmentOwner5
ApartmentOwner6
BuildingB
Apartment1
ApartmentOwner1
ApartmentOwner2
Apartment2
ApartmentOwner3
ApartmentOwner4
I have created model for all 3 types of objects, this is example for Building.
public class BuildingResponse
{
public int BuildingId { get; set; }
public string City { get; set; }
public string Address { get; set; }
}
I understand that I have to use foreach over data returned by Api 1 (over buildings), but how to achieve the rest of the requirement?
Thanks