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 WeekThreeHomeworkHandler { | |
//it is public static condition and not returning anything | |
public static void leadHandler(List<Lead> lstLeads) { | |
List<Task> listTask = new List<Task>(); // intiating a task list | |
//writing an if condition where it will create a new task when productInterest picklist has one of the values | |
//if(l.ProductInterest__c == 'Cookbook Authorship' | |
//|| l.ProductInterest__c =='Cookbook Editing' | |
//||l. ProductInterest__c =='Cookbook Distribution') | |
for (Lead l : lstLeads) { |
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 WeekThreeHomeworkHandler { | |
//it is public static condition and not returning anything | |
public static void leadHandler(List<Lead> lstLeads) { | |
List<Task> listTask = new List<Task>(); // intiating a task list | |
//writing an if condition where it will create a new task when productInterest picklist has one of the values | |
//if(l.ProductInterest__c == 'Cookbook Authorship' | |
//|| l.ProductInterest__c =='Cookbook Editing' | |
//||l. ProductInterest__c =='Cookbook Distribution') | |
for (Lead l : lstLeads) { |
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 RecipeTriggerHandler { | |
//created a method before recipe insert or update to check if it is missing any field value | |
public static void beforeRecipeInsertOrUpdate(List<Recipe__c> listRec) { | |
//looping through list of recipe and checking if any of the field missing valu | |
for (Recipe__c recipe : listRec) { | |
if ( | |
recipe.Name == null || | |
recipe.Active_Time__c == null || | |
recipe.Description__c == null || | |
recipe.Active_Time_Units__c == null || |
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
@isTest | |
private with sharing class RecipeTriggerHandler_Test { | |
@isTest | |
static void testBeforeRecipeInsertOrUpdateWithDraftTrue(){ | |
List<Recipe__c> relist = new List<Recipe__c>(); | |
Recipe__c rec = new Recipe__c(Name = 'Fist Test', | |
Active_Time__c = 20, | |
Active_Time_Units__c = 'Minutes', | |
Servings__c = 2 | |
); |
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
@isTest | |
private with sharing class RecipeTriggerHandler_Test { | |
//showing an error message when Draft__c is not true. | |
@isTest | |
static void testNegativeBeforeRecipeInsertOrUpdate(){ | |
List<Recipe__c> relist = new List<Recipe__c>(); | |
Recipe__c rec = new Recipe__c(Name = 'Fist Test', | |
Active_Time__c = 20, | |
Active_Time_Units__c = 'Minutes', |
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 inherited sharing class RecipeController { | |
@AuraEnabled | |
public static List <Ingredient__c> generateGroceryList(Id recipeId){ | |
//load the ingredients and return them | |
List<Ingredient__c> ingredientList = [Select ID, Name, Measurement__c, Measurement_Type__c, Notes__c From Ingredient__c Where Recipe__c = :recipeId]; | |
return ingredientList; | |
} |
OlderNewer