How can I iterate and grab the data for different month instead of passing month and execute the soql and return the data and I believe this code can be written better than what I'm doing here...
Here is my method that executes SOQL and pass the month and it returns the data based on the month:
public List<WrapperEmployeeTime> loadData(string month)
{
List<Employee__c> soqlData = [SELECT id,name,..... from Employee__c where month__c =: month];
List<Employee__c> loadempTime = new List<Employee__c>();
for(Employee__c e : soqlData)
{
WrapperEmployeeTime b = new WrapperEmployeeTime();
//do good stuffs here..
loadempTime.add(b);
}
return loadempTime;
}
Calling method:
public List<WrapperEmployeeTime> wrapEmployeeJanList {get;set;}
wrapEmployeeJanList = loadData('January');
public List<WrapperEmployeeTime> wrapEmployeeFebList {get;set;}
wrapEmployeeFebList = loadData('Febuary');
public List<WrapperEmployeeTime> wrapEmployeeMarList {get;set;}
wrapEmployeeMarList = loadData('March');
all the way upto 12 months....
I could pull all the data of 12 months and loop through based on the month but I'm not sure what is the best way of achieving this.