Skip to content

Instantly share code, notes, and snippets.

@asmitakhare
asmitakhare / WeekTwoHomeworkRad
Last active April 13, 2023 12:03
WeekTwoHomeworkRad
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) {
@asmitakhare
asmitakhare / WeekThreeHomeWorkClass
Last active April 13, 2023 12:13
WeekThreeHomeWork
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) {
@asmitakhare
asmitakhare / WeekFourHomework
Last active April 20, 2023 22:11
WeekFourHomework
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 ||
@asmitakhare
asmitakhare / WeekFiveHomework
Last active April 27, 2023 13:09
WeekFiveHomework
@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
);
@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',
@asmitakhare
asmitakhare / RecipeController
Last active May 25, 2023 22:17
Final Project
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;
}