示例#1
0
        public BlockedPeriod FindBlockedPeriodByDate(DateTime date)
        {
            TimeSpan now = timeManager.Now().TimeOfDay;

            return(BlockedPeriods.GetAll().Where(b => b.EndDatetime.Date > date && b.StartDatetime.Date <= date ||
                                                 b.EndDatetime.Date == date && b.EndDatetime.TimeOfDay > now)
                   .OrderByDescending(b => b.StartDatetime).FirstOrDefault());
        }
示例#2
0
        private bool IsInBlockedPeriod(DateTime date, Timeslot timeslot)
        {
            DateTime timeslotStart = date + timeslot.StartTime;
            DateTime timeslotEnd   = date + timeslot.EndTime;

            // Check if the start or end of the timeslot is inside any blocked period
            return(BlockedPeriods.Query().Where(bp =>
                                                (timeslotStart >= bp.StartDatetime && timeslotStart <= bp.EndDatetime) ||
                                                (timeslotEnd >= bp.StartDatetime && timeslotEnd <= bp.EndDatetime)
                                                ).Any());

            // Different flavor, same functionality. Choose one.
            return(BlockedPeriods.Query().Where(bp => (date > bp.StartDatetime && date < bp.EndDatetime) ||
                                                (date == bp.StartDatetime.Date && bp.StartDatetime.TimeOfDay >= timeslot.StartTime) ||
                                                (date == bp.EndDatetime.Date && bp.EndDatetime.TimeOfDay <= timeslot.EndTime))
                   .Any());
        }
示例#3
0
 public void AddBlockedPeriod(BlockedPeriod blockedPeriod)
 {
     BlockedPeriods.Add(blockedPeriod);
     BlockedPeriods.SaveChanges();
 }
示例#4
0
 public BlockedPeriod GetBlockedPeriodById(int blockId)
 {
     return(BlockedPeriods.GetAll().Where(b => b.Id == blockId).FirstOrDefault());
 }
示例#5
0
 public void DeleteBlockedPeriod(BlockedPeriod blockedPeriod)
 {
     BlockedPeriods.Delete(blockedPeriod);
     BlockedPeriods.SaveChanges();
 }
示例#6
0
        public IList <BlockedPeriod> GetAllBlockedPeriodsFuture()
        {
            DateTime now = timeManager.Now();

            return(BlockedPeriods.GetAll().Where(b => b.EndDatetime > now).OrderByDescending(b => b.StartDatetime).ToList());
        }