public bool Contain(ScheduleInterval other) { if (Start.Date != other.Start.Date) { return(false); } if (Start.Hour <= other.Start.Hour && Start.Hour + Duration >= other.Start.Hour + other.Duration) { return(true); } return(false); }
public bool IsOverlapped(ScheduleInterval other) { if (Start.Date != other.Start.Date) { return(false); } if (other.Start.Hour >= Start.Hour && other.Start.Hour <= Start.Hour + Duration) { return(true); } if (other.Start.Hour + Duration >= Start.Hour && other.Start.Hour + Duration <= Start.Hour + Duration) { return(true); } return(false); }
public bool IsScheduleIntervalAvailable(ScheduleInterval other) { var intervals = Schedule?.Where(s => s.Start.Date == other.Start.Date); if (intervals == null) { return(false); } var orderedIntervals = TrainingsSchedule?.Where(s => s.Start.Date == other.Start.Date); if (orderedIntervals?.Where(i => i.IsOverlapped(other)) != null) { return(false); } if (intervals.Any(i => i.Contain(other))) { return(true); } return(false); }