Skip to content

Instantly share code, notes, and snippets.

@benfoster
Created March 24, 2014 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benfoster/9741613 to your computer and use it in GitHub Desktop.
Save benfoster/9741613 to your computer and use it in GitHub Desktop.
Sending Subscription Notifications
/// <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