Created
October 4, 2012 04:33
-
-
Save jmarnold/3831495 to your computer and use it in GitHub Desktop.
For Gary
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 CurrentScheduleBoundary : ICurrentScheduleBoundary | |
{ | |
private readonly ISystemTime _systemTime; | |
private readonly ISchedulingGateway _gateway; | |
public CurrentScheduleBoundary(ISystemTime systemTime, ISchedulingGateway gateway) | |
{ | |
_systemTime = systemTime; | |
_gateway = gateway; | |
} | |
public bool Contains(CaseProperties properties) | |
{ | |
var now = _systemTime.LocalTime(); | |
var schedule = _gateway.GetActiveSchedule(); | |
var boundary = schedule.Period.To; | |
if(schedule.Period.From.UtcTime.Date == now.UtcTime.Date) | |
{ | |
return true; | |
} | |
if(now.UtcTime.Date > boundary.UtcTime.Date) | |
{ | |
return false; | |
} | |
var scheduledTime = properties.ScheduledTime.Value; | |
var proposedTime = now.AtTime(scheduledTime); | |
return boundary > proposedTime; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment