Requirement:
====================================================================
public PageReference modifyExpDate()
{
list<Payment_Profile__c>Updatelist=new list<Payment_Profile__c>();
map<string,Payment_Profile__C> UpdateMap=new map<string,Payment_Profile__C>();
for(Payment_Profile__C ppval:getcatInnerObjMod()){
if(ppval.Active__c == false){
ppval.Active__c = true;
}
if((integer.valueof(ppval.Expiration_Year__c)>System.Today().year())||((integer.valueof(ppval.Expiration_Year__c)==System.Today().year())&& (integer.valueof(ppval.Expiration_Month__c)>System.Today().month())))
{
if(TokenMap.get(ppval.Gateway_Token_Id__c)!=null)
{
for(Payment_Profile__C p:TokenMap.get(ppval.Gateway_Token_Id__c))
{
p.Expiration_Month__c=ppval.Expiration_Month__c;
p.Expiration_Year__c=ppval.Expiration_Year__c;
if(UpdateMap.get(p.id)==null)
UpdateMap.put(p.id,p);
}
}
UpdateMap.put(ppval.id,ppval);
}
else{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error,'Exp.Date should be future'));
continue;
}
}
if(UpdateMap.keyset().size()>0){
System.debug('UpdateMap-->'+UpdateMap);
update UpdateMap.values();
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Exp.Date modified for selected payment profiles'));
}
return null;
}
Cheers..
1. On click of save button new expiry date is a
future date.
a. It
should update the expiry date of the record which is selected.
b. It
should enable the payment profile if it is disabled
c. It
should update all the members payment profiles which all belongs to same token.
public PageReference modifyExpDate()
{
list<Payment_Profile__c>Updatelist=new list<Payment_Profile__c>();
map<string,Payment_Profile__C> UpdateMap=new map<string,Payment_Profile__C>();
for(Payment_Profile__C ppval:getcatInnerObjMod()){
if(ppval.Active__c == false){
ppval.Active__c = true;
}
if((integer.valueof(ppval.Expiration_Year__c)>System.Today().year())||((integer.valueof(ppval.Expiration_Year__c)==System.Today().year())&& (integer.valueof(ppval.Expiration_Month__c)>System.Today().month())))
{
if(TokenMap.get(ppval.Gateway_Token_Id__c)!=null)
{
for(Payment_Profile__C p:TokenMap.get(ppval.Gateway_Token_Id__c))
{
p.Expiration_Month__c=ppval.Expiration_Month__c;
p.Expiration_Year__c=ppval.Expiration_Year__c;
if(UpdateMap.get(p.id)==null)
UpdateMap.put(p.id,p);
}
}
UpdateMap.put(ppval.id,ppval);
}
else{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error,'Exp.Date should be future'));
continue;
}
}
if(UpdateMap.keyset().size()>0){
System.debug('UpdateMap-->'+UpdateMap);
update UpdateMap.values();
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Exp.Date modified for selected payment profiles'));
}
return null;
}
Cheers..
No comments:
Post a Comment