Skip to content

Commit 86c1601

Browse files
authored
Add files via upload
1 parent aefe4f0 commit 86c1601

33 files changed

+732
-2
lines changed

AccountController.cls

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
public class AccountController {
2+
//1 method
3+
/*public static List<Account> insertAccounts(List<Account> accountToInsert)
4+
{
5+
insert accountToInsert;
6+
return accountToInsert;
7+
}
8+
*/
9+
10+
//2nd method
11+
public static List<Account> getAllAccounts()
12+
{
13+
List<Account> accounts = [select Name, Phone FROM Account];
14+
return accounts;
15+
}
16+
17+
//3rd method
18+
public static void printAllAccounts()
19+
{
20+
List<Account> accounts = getAllAccounts();
21+
for(Account account: accounts)
22+
{
23+
System.debug('Acc Name: '+account.Name + 'acc Phone: '+ account.Phone);
24+
}
25+
}
26+
}

AddJpgPdf.cls

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class AddJpgPdf {
2+
public static void copying(){
3+
Account accAdd = [select id,name from Account where Name like '%Deepak%' limit 1];
4+
Opportunity op = new Opportunity();
5+
op.AccountId = accAdd.Id;
6+
op.Name = 'Rawat';
7+
8+
Insert op;
9+
10+
List<ContentDocumentLink> cdl = [select LinkedEntityId, ContentDocumentId, ShareType from ContentDocumentLink where LinkedEntityId='0015j00000Xrl7JAAR'];
11+
12+
for(ContentDocumentLink cod: cdl){
13+
ContentDocumentLink cd = new ContentDocumentLink();
14+
cd.ContentDocumentId = cod.ContentDocumentId;
15+
cd.LinkedEntityId =op.Id;
16+
cd.ShareType='v';
17+
18+
Insert cd;
19+
}
20+
}
21+
}

Binaryadd.cls

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
public class Binaryadd {
2+
public static void Add()
3+
{
4+
String s1 = '0101101', s2 = '100101', str;
5+
Integer a,b,rem;
6+
Double n1=0,n2=0;
7+
8+
List<String> Output = new List<String>();
9+
10+
a = integer.valueOf(s1);
11+
b = integer.valueOf(s2);
12+
13+
//Converting Binary To Integer of S1
14+
for(Integer i=0;i<s1.length();i++)
15+
{
16+
rem = Math.mod(a, 10);
17+
a=a/10;
18+
if(Rem==1)
19+
n1 = n1+Math.pow(2, i);
20+
}
21+
22+
//Converting Binary To Integer of S2
23+
for(Integer i=0;i<s2.length();i++)
24+
{
25+
rem = Math.mod(b, 10);
26+
b=b/10;
27+
if(rem==1)
28+
n2 = n2+Math.pow(2, i);
29+
}
30+
31+
Double Num = n1+n2;
32+
33+
//Converting Double to Integer
34+
integer x = Num.intValue();
35+
36+
//Converting Integr To Binary
37+
for(Integer i=0;x!=0;i++)
38+
{
39+
rem=Math.mod(x, 2);
40+
x=x/2;
41+
if(rem==1)
42+
Output.add('1');
43+
else
44+
Output.add('0');
45+
}
46+
47+
str = Output.toString();
48+
System.debug(str.reverse());
49+
}
50+
51+
}

CalculateBMI.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ public class CalculateBMI {
1818
Decimal pace = distance / hr;
1919
return pace;
2020
}
21-
}
21+
}

ConcatenateContactAccount.cls

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public class ConcatenateContactAccount {
2+
public static void concatenateCA(){
3+
Integer Count = 0;
4+
Account acc = [select Name from Account limit 1];
5+
List<Contact> conList = [select id, FirstName, LastName from Contact];
6+
7+
List<Contact> contacts = [select id from Contact where AccountId = :acc.Id];
8+
9+
for(Contact con : contacts){
10+
count++;
11+
}
12+
List<Account> accounts = [select Name from Account where Name like '%Deepak%'];
13+
for(Account ac : accounts){
14+
ac.Name = ac.name + count;
15+
}
16+
update accounts;
17+
}
18+
}

CreateCase.cls

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//WAP to create 5 Case Records with all the values(Account, Contact, etc) filled in.
2+
public class CreateCase {
3+
public static void getcase(){
4+
5+
Account acc = [select Id, Name from Account where Name Like 'Deepak0'];
6+
Contact con = [select Id, Name from Contact where Name Like '%Deepak0%'];
7+
Product2 pro = [SELECT Id, Name FROM Product2 where Name like '%product0%'];
8+
9+
List<Case> addcase = new List<Case>();
10+
for(integer i=0;i<5;i++)
11+
{
12+
Case objcase = new Case();
13+
14+
objcase.Status = 'New';
15+
objcase.Origin = 'Phone';
16+
objcase.Type = 'Mechanical';
17+
objcase.SuppliedEmail='[email protected]';
18+
objcase.SuppliedName = 'deepak';
19+
objcase.SuppliedPhone = '8126263844';
20+
objcase.Reason = 'BreakDown';
21+
objcase.Subject = 'Subject testing';
22+
objcase.Description = 'Description Testing...';
23+
24+
objcase.AccountId = acc.Id;
25+
objcase.ContactId = con.Id;
26+
objcase.ProductId = pro.Id;
27+
28+
addcase.add(objcase);
29+
}
30+
Insert addcase;
31+
32+
}
33+
}

CreatePriceBook.cls

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//Create new price book 'Algo Price Book' and 10 products with Prices in the Pricebook
2+
public class CreatePriceBook {
3+
4+
public static List<Product2> createProduct(Integer productQuantity){
5+
List<Product2> productList = new List<Product2>();
6+
for(Integer i=1; i<=10; ++i){
7+
Product2 prod = new Product2();
8+
prod.Name = 'Product Example 1: '+i;
9+
prod.IsActive = True;
10+
productList.add(prod);
11+
}
12+
if(!productList.isEmpty()){
13+
Insert productList;
14+
}
15+
Pricebook2 stdPb = [select Id, IsStandard from Pricebook2 where IsStandard = true Limit 1];
16+
List<PricebookEntry> pbeList = new List<PricebookEntry>();
17+
for(Product2 prod: productList){
18+
PricebookEntry pbe = new PricebookEntry();
19+
20+
pbe.Product2Id = prod.Id;
21+
pbe.Pricebook2Id = stdPb.Id;
22+
pbe.UnitPrice = 2;
23+
pbeList.add(pbe);
24+
}
25+
Insert pbeList;
26+
return productList;
27+
}
28+
29+
public static void createCustomPricebook(){
30+
Pricebook2 custPricebook = new Pricebook2();
31+
custPricebook.Name = 'abc Pricebook';
32+
Insert custPricebook;
33+
List<Product2> prodList = createProduct(5);
34+
}
35+
}

CreateProduct.cls

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class CreateProduct {
2+
public static void getProd(){
3+
List<Product2> proL = new List<Product2>();
4+
for(Integer i=0;i<10;++i)
5+
{
6+
Product2 pro = new Product2();
7+
pro.Name = 'Product Testing 1: '+i;
8+
pro.Family = 'nuclear';
9+
10+
proL.add(pro);
11+
}
12+
Insert proL;
13+
}
14+
}

CreateRecords.cls

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class CreateRecords {
2+
public static void creating()
3+
{
4+
List<Account> accountList = new List<Account>();
5+
for(Integer i=0;i<2;i++){
6+
Account acco = new Account();
7+
acco.Name = 'testing 1: '+i;
8+
acco.BillingCity = 'Delhi';
9+
acco.Phone = '123456789';
10+
acco.AnnualRevenue = 20000;
11+
acco.Fax = '123';
12+
accountList.add(acco);
13+
}
14+
if(!accountList.isEmpty())
15+
{
16+
Insert accountList;
17+
}
18+
}
19+
}

DeleteRec.cls

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//Delete all contacts belonging to Accounts Name FIELD having 'A' in them.
2+
public class DeleteRec {
3+
public static void AddContact(){
4+
List<Account> accountList = new List<Account>();
5+
accountList = [Select Id, Name From Account Where Name Like '%a%' LIMIT 10];
6+
7+
set<Id> accIdSet = new set<Id>();
8+
for(Account acc : accountList){
9+
accIdSet.add(acc.Id);
10+
}
11+
12+
List<Contact> conList = new List<Contact>();
13+
/*conList = [select Id, Name, AccountId from contact where AccountId IN: accIdSet limit 50000];
14+
*/
15+
//or
16+
17+
//child to parent
18+
conList = [select Id, Name, AccountId, Account.Name from Contact where Account.Name Like '%a%' limit 50000];
19+
delete conList;
20+
21+
}
22+
23+
}

DiffDates.cls

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class DiffDates {
2+
public static void getDiff(){
3+
4+
Datetime startdate = Datetime.newInstance(2016, 01, 06, 06, 07, 55);
5+
Datetime enddate = Datetime.newInstance(2016, 02, 05, 07, 08, 55);
6+
7+
Integer year = startdate.year()-enddate.year();
8+
Integer month = startdate.month()-enddate.month();
9+
Integer days = startdate.day()-enddate.day();
10+
Integer hour = startdate.hour()-enddate.hour();
11+
Integer minute = startdate.minute()-enddate.minute();
12+
Integer second = startdate.second()-enddate.second();
13+
14+
System.debug('Difference between two dates=>'+year+'Years'+month+'Months'+days+'Days'+hour+'Hours'+minute+'Minutes'+second+'Seconds');
15+
16+
}
17+
}

Fibonacci.cls

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//Print the fibonacci series. 1, 1, 2, 3, 5, 8, 13..
2+
public class Fibonacci {
3+
public static void fib(){
4+
integer num1,num2,temp;
5+
num1=num2=1;
6+
for(integer i=1;i<=7;i++){
7+
system.debug(num1);
8+
temp=num1+num2;
9+
num1=num2;
10+
num2=temp;
11+
}
12+
}
13+
}

FindHighestPrice.cls

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class FindHighestPrice {
2+
public static void getHP(){
3+
AggregateResult pricebookentry = [select max(UnitPrice) from PricebookEntry];
4+
// If you have multiple unnamed columns you reference in the order called with expr0, expr1, expr2, etc.
5+
Double doublepbe = Double.valueOf(pricebookentry.get('expr0'));
6+
System.debug(doublepbe);
7+
/*
8+
List<PricebookEntry> pbookList = [select Product2.Name from pricebookEntry where UnitPrice = :doublepbe limit 1];
9+
for(pricebookEntry p: pbookList){
10+
System.debug(P.Product2.Name+ '-->' +doublepbe);
11+
}*/
12+
13+
}
14+
}

GetUserDetails.cls

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public class GetUserDetails {
2+
public static void printUserDetails(){
3+
User objUser = new User();
4+
objUser = [SELECT id,Name,Email,Phone FROM User WHERE Id = :Userinfo.getUserId()];
5+
System.debug('user Details: '+objUser);
6+
System.debug('user Phone NO: '+objUser.Phone);
7+
}
8+
}

HighestunitPrice.cls

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public class HighestunitPrice {
2+
3+
}

InsertChild.cls

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class InsertChild {
2+
public static void insertchilds(){
3+
child__c children = new child__c();
4+
children.Name = 'deepak child';
5+
6+
insert children;
7+
System.debug('child>>'+children);
8+
}
9+
}

InsertContact.cls

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//Create 10 Contacts with different Account(LookUp) values(Relationship) with no same 2 account in them.
2+
public class InsertContact {
3+
public static void InsertCon(){
4+
5+
List<Account> accList = new List<Account>();
6+
accList = [select id, name from Account LIMIT 20];
7+
8+
list<Contact> listconn = new list<Contact>();
9+
Integer k=0;
10+
for(integer i=1;i<10;++i){
11+
k=k+1;
12+
Contact con = new Contact();
13+
con.LastName = accList.get(k).Name;
14+
con.AccountId = accList.get(k).Id;
15+
listconn.add(con);
16+
}
17+
Insert listconn;
18+
System.debug(listconn);
19+
}
20+
}

InsertMentor.cls

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public class InsertMentor {
2+
public static void insertparent(){
3+
parent__c parent = new parent__c();
4+
parent.Name = 'deepak parent';
5+
parent.email__c = '[email protected]';
6+
7+
Insert parent ;
8+
System.debug('parent>>'+parent);
9+
}
10+
}

OppGetStatusAmount.cls

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//Find the the Opportunity which status is closed Won and has highest amount.
2+
public class OppGetStatusAmount {
3+
public static void PrintSA(){
4+
List<AggregateResult> agr = new List<AggregateResult>();
5+
agr = [select StageName, MAX(Amount) FROM Opportunity Where StageName = 'Closed Won' GROUP BY StageName];
6+
System.debug('->'+agr);
7+
}
8+
}

PersonAccount.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ public class PersonAccount {
4242
pac.Name = 'Deepak pa 1: 4';
4343
update pac;
4444
}
45-
}
45+
}

0 commit comments

Comments
 (0)