Created
July 3, 2017 08:06
-
-
Save bandicoot86/5458f980ac9b13327416b0e5e2e7a5d5 to your computer and use it in GitHub Desktop.
Custom event helper to do the logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomEventHelper { | |
public Boolean timeAv(DateTime s, DateTime e, Id accId, Id cid) { | |
Boolean allowed = false; | |
try { | |
Long c = [SELECT count() FROM CustomEvent__c WHERE Account__c=:accId | |
AND | |
( | |
(StartDate__c <=:s AND EndDate__c >=:s) OR | |
(StartDate__c <=:e AND EndDate__c >=:e) OR | |
(StartDate__c>=:s AND EndDate__c<=:e) | |
) | |
AND Id<>:cid]; | |
allowed = c == 0; | |
} catch (Exception ex){ | |
system.debug('Error ' + ex.getMessage()); | |
} | |
return allowed; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment