Created
February 20, 2019 19:20
-
-
Save choudharymanish8585/8e4ccb2046b01a256d2a93f3a427bf46 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class CarSearchController { | |
@AuraEnabled | |
public static List<Car__c> getCars(String carTypeId){ | |
//If 'All Type' selected on UI, below code will execute to get all cars | |
if(carTypeId.equalsIgnoreCase('')){ | |
return [SELECT id, Name, Picture__c, Contact__r.Name, | |
Geolocation__latitude__s, Geolocation__longitude__s | |
FROM Car__c | |
WHERE Available_For_Rent__c = true ]; | |
} | |
//If any specific car type is selected on UI, below code will execute | |
//to get all cars of that type | |
else{ | |
//system.debug('SELECT id, Name, Picture__c FROM Boat__c WHERE id = :'+boatTypeId); | |
return [SELECT id, Name, Picture__c, Contact__r.Name, | |
Geolocation__latitude__s, Geolocation__longitude__s | |
FROM Car__c | |
WHERE Car_Type__c=: carTypeId | |
AND Available_For_Rent__c = true]; | |
} | |
} | |
@AuraEnabled | |
public static List<Car__c> getAllCars(){ | |
//If 'All Type' selected on UI, below code will execute to get all cars | |
return [SELECT Id, Name, Picture__c, Contact__r.Name, | |
Build_Year__c , Per_Day_Rent__c , Mileage__c, Available_For_Rent__c, | |
Geolocation__latitude__s, Geolocation__longitude__s | |
FROM Car__c ]; | |
} | |
@AuraEnabled | |
public static List<Contact> getContacts(){ | |
List<Contact> contacts = new List<Contact>(); | |
for(Contact con : [SELECT Id, Name, Phone, Email, (Select Id, Name From Cars__r) From Contact]){ | |
for(Car__c car : con.Cars__r){ | |
contacts.add(con); | |
} | |
} | |
return contacts; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment