Notes
public class CaseUtility {
public static Case getCaseById(Id caseID){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case WHERE Id =:caseID];
}
public static List<Case> getCasesByAccountId(Id acID){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case WHERE AccountID =:acID];
}
public static Case getCasesByContactId(Id conId){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case WHERE Id =:conId];
}
public static List<Case> getNewCasesByStatus(String st){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case WHERE Status =:st];
}
public static List<Case> getNewCasesByPriority(String pr){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case WHERE Priority =:pr];
}
public static List<Case> getClosedCases(){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case WHERE Status = 'Closed'];
}
public static List<Case> getOpenedCases(){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case WHERE Status != 'Closed'];
}
public static List<Case> getCasesWithoutAccount(){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case WHERE AccountId=Null];
}
public static List<Case> getCasesWithAccount(){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case WHERE AccountId!=Null];
}
public static List<Case> getCasesWithoutContact(){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case WHERE ContactId=Null];
}
public static List<Case> getCasesWithContact(){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case WHERE ContactId != Null];
}
public static Integer getNumberOfCases(){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case].size();
}
public static Integer getNumberOfOpenCases(){
return [SELECT Id, Status, Origin, Priority, AccountId, ContactId, Subject FROM Case WHERE Status != 'Closed'].size();
}
}