Пример #1
0
        private static IList <ScheduleSlot> GenerateAvailableTimeSlots(IList <ScheduleSlot> scheduleList, ScheduleSlot bounds)
        {
            List <ScheduleSlot> spareTimeSlots = new List <ScheduleSlot>();

            for (int i = 0; i < scheduleList.Count; i++)
            {
                if (i == 0 && scheduleList[i].StartTime > bounds.StartTime)
                {
                    spareTimeSlots.Add(new ScheduleSlot
                    {
                        StartTime = bounds.StartTime,
                        EndTime   = scheduleList[i].StartTime
                    });
                }
                if (i == scheduleList.Count - 1)
                {
                    if (scheduleList[i].EndTime < bounds.EndTime)
                    {
                        spareTimeSlots.Add(new ScheduleSlot
                        {
                            StartTime = scheduleList[i].EndTime,
                            EndTime   = bounds.EndTime
                        });
                    }
                }
                else if (scheduleList[i].EndTime != scheduleList[i + 1].StartTime)
                {
                    spareTimeSlots.Add(new ScheduleSlot
                    {
                        StartTime = scheduleList[i].EndTime,
                        EndTime   = scheduleList[i + 1].StartTime
                    });
                }
            }
            return(spareTimeSlots);
        }
Пример #2
0
 private static bool Filter(ScheduleSlot slot, ScheduleSlot hostSpareTimeSlot) =>
 (slot.StartTime >= hostSpareTimeSlot.StartTime && slot.StartTime <= hostSpareTimeSlot.EndTime) ||
 (slot.EndTime >= hostSpareTimeSlot.StartTime && slot.EndTime <= hostSpareTimeSlot.EndTime);