179 lines
10 KiB
OpenEdge ABL
179 lines
10 KiB
OpenEdge ABL
public with sharing class PropertyDataController {
|
|
|
|
@AuraEnabled(cacheable=true)
|
|
public static List<pcrm__Property__c> getProperties() {
|
|
try {
|
|
System.debug('=== FETCHING ALL PROPERTIES FROM PCRM OBJECT ===');
|
|
|
|
// Query using fields that are actually available in pcrm__Property__c
|
|
String query = 'SELECT Id, Name, ' +
|
|
'pcrm__Property_Type__c, pcrm__Status__c, ' +
|
|
'pcrm__Bathrooms__c, pcrm__Bedrooms__c, pcrm__Size__c, ' +
|
|
'pcrm__Sale_Price_min__c, pcrm__Sale_Price_max__c, ' +
|
|
'pcrm__Rent_Price_min__c, pcrm__Rent_Price_max__c, ' +
|
|
'pcrm__Description_English__c, pcrm__Title_English__c, ' +
|
|
'pcrm__City_Bayut_Dubizzle__c, pcrm__Community_Propertyfinder__c, ' +
|
|
'pcrm__Furnished__c, pcrm__Floor__c, pcrm__Build_Year__c, ' +
|
|
'pcrm__Parking_Spaces__c, pcrm__Offering_Type__c, ' +
|
|
'pcrm__Unit_Number__c, pcrm__Locality_Bayut_Dubizzle__c, ' +
|
|
'pcrm__Sub_Locality_Bayut_Dubizzle__c, pcrm__Tower_Bayut_Dubizzle__c, ' +
|
|
'pcrm__Sub_Community_Propertyfinder__c, pcrm__Property_Name_Propertyfinder__c, ' +
|
|
'pcrm__City_Propertyfinder__c, ' +
|
|
'pcrm__Rent_Available_From__c, pcrm__Rent_Available_To__c, ' +
|
|
'Contact__c, Contact__r.FirstName, Contact__r.LastName, Contact__r.Email, Contact__r.Phone, ' +
|
|
'Email__c, Phone__c, ' +
|
|
'CreatedBy.Name, LastModifiedBy.Name, Owner.Name, ' +
|
|
'CreatedDate, LastModifiedDate ' +
|
|
'FROM pcrm__Property__c ' +
|
|
'ORDER BY Name ASC';
|
|
|
|
List<pcrm__Property__c> properties = Database.query(query);
|
|
|
|
System.debug('=== PROPERTIES FETCHED FROM PCRM ===');
|
|
System.debug('Total properties found: ' + properties.size());
|
|
|
|
// Log first property details for debugging
|
|
if (!properties.isEmpty()) {
|
|
pcrm__Property__c firstProp = properties[0];
|
|
System.debug('First property details:');
|
|
System.debug('Name: ' + firstProp.Name);
|
|
System.debug('Type: ' + firstProp.pcrm__Property_Type__c);
|
|
System.debug('Status: ' + firstProp.pcrm__Status__c);
|
|
System.debug('Bedrooms: ' + firstProp.pcrm__Bedrooms__c);
|
|
System.debug('Bathrooms: ' + firstProp.pcrm__Bathrooms__c);
|
|
System.debug('Size: ' + firstProp.pcrm__Size__c);
|
|
System.debug('Sale Price Min: ' + firstProp.pcrm__Sale_Price_min__c);
|
|
System.debug('Sale Price Max: ' + firstProp.pcrm__Sale_Price_max__c);
|
|
System.debug('Rent Price Min: ' + firstProp.pcrm__Rent_Price_min__c);
|
|
System.debug('Rent Price Max: ' + firstProp.pcrm__Rent_Price_max__c);
|
|
System.debug('City: ' + firstProp.pcrm__City_Bayut_Dubizzle__c);
|
|
System.debug('Community: ' + firstProp.pcrm__Community_Propertyfinder__c);
|
|
System.debug('Description: ' + firstProp.pcrm__Description_English__c);
|
|
System.debug('Title: ' + firstProp.pcrm__Title_English__c);
|
|
System.debug('Furnished: ' + firstProp.pcrm__Furnished__c);
|
|
System.debug('Floor: ' + firstProp.pcrm__Floor__c);
|
|
System.debug('Build Year: ' + firstProp.pcrm__Build_Year__c);
|
|
System.debug('Parking Spaces: ' + firstProp.pcrm__Parking_Spaces__c);
|
|
System.debug('Offering Type: ' + firstProp.pcrm__Offering_Type__c);
|
|
}
|
|
|
|
return properties;
|
|
|
|
} catch (Exception e) {
|
|
System.debug('Error fetching properties: ' + e.getMessage());
|
|
System.debug('Stack trace: ' + e.getStackTraceString());
|
|
throw new AuraHandledException('Failed to fetch properties: ' + e.getMessage());
|
|
}
|
|
}
|
|
|
|
@AuraEnabled(cacheable=true)
|
|
public static pcrm__Property__c getPropertyDetails(String propertyId) {
|
|
try {
|
|
System.debug('=== FETCHING COMPLETE PROPERTY DETAILS FROM PCRM ===');
|
|
System.debug('Property ID: ' + propertyId);
|
|
|
|
// Query using fields that are actually available in pcrm__Property__c
|
|
String query = 'SELECT Id, Name, ' +
|
|
'pcrm__Property_Type__c, pcrm__Status__c, ' +
|
|
'pcrm__Bathrooms__c, pcrm__Bedrooms__c, pcrm__Size__c, ' +
|
|
'pcrm__Sale_Price_min__c, pcrm__Sale_Price_max__c, ' +
|
|
'pcrm__Rent_Price_min__c, pcrm__Rent_Price_max__c, ' +
|
|
'pcrm__Description_English__c, pcrm__Title_English__c, ' +
|
|
'pcrm__City_Bayut_Dubizzle__c, pcrm__Community_Propertyfinder__c, ' +
|
|
'pcrm__Furnished__c, pcrm__Floor__c, pcrm__Build_Year__c, ' +
|
|
'pcrm__Parking_Spaces__c, pcrm__Offering_Type__c, ' +
|
|
'pcrm__Unit_Number__c, pcrm__Locality_Bayut_Dubizzle__c, ' +
|
|
'pcrm__Sub_Locality_Bayut_Dubizzle__c, pcrm__Tower_Bayut_Dubizzle__c, ' +
|
|
'pcrm__Sub_Community_Propertyfinder__c, pcrm__Property_Name_Propertyfinder__c, ' +
|
|
'pcrm__City_Propertyfinder__c, ' +
|
|
'pcrm__Rent_Available_From__c, pcrm__Rent_Available_To__c, ' +
|
|
'Contact__c, Contact__r.FirstName, Contact__r.LastName, Contact__r.Email, Contact__r.Phone, ' +
|
|
'Email__c, Phone__c, ' +
|
|
'CreatedBy.Name, LastModifiedBy.Name, Owner.Name, ' +
|
|
'CreatedDate, LastModifiedDate ' +
|
|
'FROM pcrm__Property__c ' +
|
|
'WHERE Id = :propertyId';
|
|
|
|
pcrm__Property__c property = Database.query(query);
|
|
|
|
if (property != null) {
|
|
System.debug('=== PROPERTY DETAILS FETCHED FROM PCRM ===');
|
|
System.debug('Name: ' + property.Name);
|
|
System.debug('Type: ' + property.pcrm__Property_Type__c);
|
|
System.debug('Status: ' + property.pcrm__Status__c);
|
|
System.debug('Bedrooms: ' + property.pcrm__Bedrooms__c);
|
|
System.debug('Bathrooms: ' + property.pcrm__Bathrooms__c);
|
|
System.debug('Size: ' + property.pcrm__Size__c);
|
|
System.debug('Sale Price Min: ' + property.pcrm__Sale_Price_min__c);
|
|
System.debug('Sale Price Max: ' + property.pcrm__Sale_Price_max__c);
|
|
System.debug('Rent Price Min: ' + property.pcrm__Rent_Price_min__c);
|
|
System.debug('Rent Price Max: ' + property.pcrm__Rent_Price_max__c);
|
|
System.debug('City: ' + property.pcrm__City_Bayut_Dubizzle__c);
|
|
System.debug('Community: ' + property.pcrm__Community_Propertyfinder__c);
|
|
System.debug('Description: ' + property.pcrm__Description_English__c);
|
|
System.debug('Title: ' + property.pcrm__Title_English__c);
|
|
System.debug('Furnished: ' + property.pcrm__Furnished__c);
|
|
System.debug('Floor: ' + property.pcrm__Floor__c);
|
|
System.debug('Build Year: ' + property.pcrm__Build_Year__c);
|
|
System.debug('Parking Spaces: ' + property.pcrm__Parking_Spaces__c);
|
|
System.debug('Offering Type: ' + property.pcrm__Offering_Type__c);
|
|
}
|
|
|
|
return property;
|
|
|
|
} catch (Exception e) {
|
|
System.debug('Error fetching property details: ' + e.getMessage());
|
|
System.debug('Stack trace: ' + e.getStackTraceString());
|
|
throw new AuraHandledException('Failed to fetch property details: ' + e.getMessage());
|
|
}
|
|
}
|
|
|
|
@AuraEnabled(cacheable=true)
|
|
public static Integer getPropertyCount() {
|
|
try {
|
|
return [SELECT COUNT() FROM pcrm__Property__c];
|
|
} catch (Exception e) {
|
|
System.debug('Error getting property count: ' + e.getMessage());
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
@AuraEnabled(cacheable=true)
|
|
public static List<Map<String, Object>> getPropertyImages(String propertyId) {
|
|
try {
|
|
System.debug('=== FETCHING PROPERTY IMAGES ===');
|
|
System.debug('Property ID: ' + propertyId);
|
|
|
|
List<Map<String, Object>> images = new List<Map<String, Object>>();
|
|
|
|
// Query Image Genie records for this property
|
|
List<pcrm__Image_Genie__c> imageRecords = [
|
|
SELECT Id, Name, pcrm__Category__c, pcrm__Title__c, Public_URL__c, pcrm__Property__c
|
|
FROM pcrm__Image_Genie__c
|
|
WHERE pcrm__Property__c = :propertyId
|
|
ORDER BY pcrm__Category__c, Name
|
|
];
|
|
|
|
System.debug('Found ' + imageRecords.size() + ' image records');
|
|
|
|
for (pcrm__Image_Genie__c img : imageRecords) {
|
|
Map<String, Object> imageData = new Map<String, Object>();
|
|
imageData.put('id', img.Id);
|
|
imageData.put('name', img.pcrm__Title__c);
|
|
imageData.put('category', img.pcrm__Category__c);
|
|
imageData.put('url', img.Public_URL__c);
|
|
images.add(imageData);
|
|
|
|
System.debug('Image: ' + img.pcrm__Title__c + ' - Category: ' + img.pcrm__Category__c + ' - URL: ' + img.Public_URL__c);
|
|
}
|
|
|
|
return images;
|
|
|
|
} catch (Exception e) {
|
|
System.debug('Error fetching property images: ' + e.getMessage());
|
|
System.debug('Stack trace: ' + e.getStackTraceString());
|
|
throw new AuraHandledException('Failed to fetch property images: ' + e.getMessage());
|
|
}
|
|
}
|
|
}
|