Could anyone help on this issue.
In the below apex class I have method called getWrapAccounts().In this method for loop allows duplicate values.I have a Login__c field,It is emailID based on thid id how can I avoid duplicate emails entering into loop.
public with sharing class WebinarDetailsExtension {
public String pageId = Apexpages.currentPage().getParameters().get('id');
public List<Webinar__c> ws = new List<Webinar__c>();
public List<WebinarAttendeesWrapper> WebinarAttendeesWrapperList = new List<WebinarAttendeesWrapper>();
public String popupvalue{get; set;}
list<Webinar_Attendees__c> selectedContacts = new list<Webinar_Attendees__c>();
public WebinarDetailsExtension(Apexpages.StandardController stdcController){
Webinar__c w = [select id,Name,Start_Time__c,Finish_Time__c,Registration_URL__c,Expired__c from Webinar__c where id = : pageId];
eventid = w.SCO_ID__c;
eventName = w.Id;
ws.add(w);
}
//Get list of Attendees of the Webinar
public List<WebinarAttendeesWrapper> getWrapAccounts() {
List<Webinar_Attendees__c> ld = [select Id,Name,principal_id__c,Login__c,isLead__c,Attandance_Status__c,Duration_Spend__c,Company_Name__c,City__c,
State__c,Country__c,Opportunity__c,Mobile_Phone__c,WebinarContact__c,Salesforce_Lead__c,Email_Sent__c,Voucher_Number__c,
Voucher_Number__r.Name from Webinar_Attendees__c where Webinar__c = : pageId AND CreatedDate <= TODAY
ORDER BY LastModifiedDate DESC NULLS FIRST LIMIT : limitsize OFFSET : count ];
// this prints two records
system.debug('list of attendees:: '+ ld);
//Here "Login__c" is an email address.only unic email id's enterig into loop.
for (Webinar_Attendees__c aa : ld) {
//how to set a condition for to avoid duplicates
If(Login__c){
WebinarAttendeesWrapperList.add(new WebinarAttendeesWrapper(aa));
}
}
//This prints 6 records ,each record prints 2 times.duplicates are added
system.debug('WebinarAttendeesWrapperList 2:: '+ WebinarAttendeesWrapperList);
return WebinarAttendeesWrapperList;
}
//Wrapper class
public class WebinarAttendeesWrapper {
public Webinar_Attendees__c acc {get; set;}
public Boolean selected {get; set;}
public WebinarAttendeesWrapper(Webinar_Attendees__c a){
acc = a;
selected = false;
}
}
}