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; | |
} |
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
@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
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
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
/** | |
* A Utility class to process Stock Item records from the Stock Item Handler | |
*/ | |
public with sharing class StockItemHandler { | |
/** | |
* Class constructor. | |
*/ | |
public StockItemHandler() { | |
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 WeekEightHomework { | |
//Assignment: The following method is supposed to create the number of accounts specified in the argument that it takes. | |
//Each Account should be named 'Sample Account #sampleNumber' where sample number is the count. So if you created 2 Accounts | |
//one would be called 'Sample Account 1' and the other 'Sample Account 2' | |
//Also, when we're done inserting them, we will create a case for each one with a Status of 'New', Origin of 'New Account' and the | |
//desription and subject of your choice. | |
//This isn't working quite right. Can you use your debugging skills to fix it? I had to comment it out since it won't compile |
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
//We're calling this 'BadAccountTrigger' because this trigger has business logic directly coded in the trigger file. It's also using | |
//way more parameters (on line 7) than it actually uses in the trigger itself. Both of these are considered bad practice. | |
//Business logic coded directly in a trigger and having extra stuff in your code both make the code hard to read and hard to maintain. | |
//The 'GoodAccountTrigger' shows how to use a handler class with your trigger and is much simpler to read. | |
//For more information on trigger syntax: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_syntax.htm | |
trigger AccountTriggerBad on Account (before insert, before update, before delete, after insert, after update, after delete, after undelete) { | |
//Each section of code below handles a different event & timing combination. For now, we are demonstrating a trigger that has all of the logic right here. | |
//Later on we'll be looking at other ways of handling Trigger events u |
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
<apex:page Controller="CaseListClass"> | |
<apex:pageBlock > | |
<apex:pageBlockTable value="{!cases}" var="c"> | |
<apex:column value="{!c.Id}"/> | |
<apex:column value="{!c.Type}"/> | |
<apex:column value="{!c.CaseNumber}"/> | |
<apex:column value="{!c.Reason}"/> | |
</apex:pageBlockTable> |
NewerOlder