Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.5 kB
0
Indexable
Never
@AuraEnabled(cacheable=true)

public static List<BuildingWrapper> getBuildingData() {

    List<BuildingWrapper> buildingWrappers = new List<BuildingWrapper>();

    List<Prohibited_Building_List_Registration__c> prohibitedBuildings = [SELECT Id, Name, Create_Date__c, Owner_Name__c, Status__c, 

                                                              (SELECT Address__c FROM Building_Addresses__r)

                                                             FROM Prohibited_Building_List_Registration__c

                                                             WHERE Status__c IN ('Draft', 'Submited', 'Approved', 'Void')

                                                             ];

    System.debug(prohibitedBuildings);

    for (Prohibited_Building_List_Registration__c pb : prohibitedBuildings) {

    System.debug(pb);

    if (pb.Building_Addresses__r.isEmpty()) {

        buildingWrappers.add(new BuildingWrapper(pb, null));

    } else {

        for (Building_Address__c ba : pb.Building_Addresses__r) {

            System.debug(ba);

            buildingWrappers.add(new BuildingWrapper(pb, ba));

        }

    }

}

return buildingWrappers;