Created
April 11, 2021 21:11
-
-
Save melissajhansen/e1186b849f38b141c76eadb7c7bd4fad to your computer and use it in GitHub Desktop.
The existing RecipeController class with your assigned method signatures added
This file contains 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 inherited sharing class RecipeController { | |
@AuraEnabled | |
public static List < Ingredient__c > generateGroceryList(Id recipeId){ | |
//load the ingredients and return them | |
} | |
@AuraEnabled | |
public static void addIngredient(String ingredientName, Integer measurementAmount, String measurementType, ID recipeId){ | |
//Insert the ingredient | |
} | |
@AuraEnabled | |
public static List < Ingredient__c > scaleRecipeForServings (ID recipeId, Decimal desiredServings) { | |
//Scale the recipe and return the list of scaled ingredients | |
} | |
@AuraEnabled(Cacheable=true) | |
public static Recipe__c[] getAllRecipes() { | |
return [ | |
SELECT | |
Id, | |
Name, | |
Draft__c, | |
Active_Time__c, | |
Active_Time_Units__c, | |
Complexity__c, | |
Needs_Review__c, | |
Possible_Duplicate__c, | |
Season__c | |
FROM Recipe__c | |
ORDER BY Name | |
LIMIT 50 | |
]; | |
} | |
@AuraEnabled(Cacheable=true) | |
public static Recipe__c[] searchRecipes(String searchTerm) { | |
// Return all recipes when no search term | |
searchTerm = searchTerm.trim(); | |
if (searchTerm == '') { | |
System.debug('returning: '+getAllRecipes()); | |
return getAllRecipes(); | |
} | |
// Prepare query paramters | |
searchTerm = '%' + searchTerm + '%'; | |
// Execute search query | |
return [ | |
SELECT | |
Id, | |
Name, | |
Draft__c, | |
Active_Time__c, | |
Active_Time_Units__c, | |
Complexity__c, | |
Needs_Review__c, | |
Possible_Duplicate__c, | |
Season__c | |
FROM Recipe__c | |
WHERE Name LIKE :searchTerm | |
ORDER BY Name | |
LIMIT 50 | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment