Skip to content

Instantly share code, notes, and snippets.

@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;
}
@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 / 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
);
@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 / 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 / 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 / StockItemHandler.Apxc Final project
Last active October 14, 2020 00:16
StockItemHandler.Apxc FinalProject.Asmita
/**
* A Utility class to process Stock Item records from the Stock Item Handler
*/
public with sharing class StockItemHandler {
/**
* Class constructor.
*/
public StockItemHandler() {
@asmitakhare
asmitakhare / Asmita WeekEightHomework.apxc
Last active October 6, 2020 18:06
Asmita WeekEightHomework.apxc
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
@asmitakhare
asmitakhare / AsmitaWeekSevenHomework.apxc
Created September 28, 2020 11:15
Asmita Week 7 home work
//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
@asmitakhare
asmitakhare / controller class
Created September 25, 2020 21:27
controller class
<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>