Created
March 24, 2014 14:51
-
-
Save benfoster/9741613 to your computer and use it in GitHub Desktop.
Sending Subscription Notifications
This file contains 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
/// <summary> | |
/// Determines whether a notification is due in the given <param name="period"/>. | |
/// </summary> | |
/// <param name="period">The notification period to check.</param> | |
/// <returns>True if a notification is due, otherwise False.</returns> | |
public bool IsNotificationDue(TimeSpan period) | |
{ | |
Ensure.Argument.NotNull(period, "period"); | |
var periodStart = NextRenewalDate - period; | |
if (periodStart <= DateTime.UtcNow) | |
{ | |
// this notification period has started | |
if (NotificationSentDate == null || NotificationSentDate < periodStart) | |
{ | |
// we've not yet sent this notification or a later one has already been sent | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment