private static Expression <Func <TimeSlot, bool> > HasDetails(IBasicSessionDetails details) { return(timeSlot => timeSlot.PrimaryService.Type == details.PrimaryServiceType && timeSlot.Chamber.Id == details.ChamberId && timeSlot.Room.Id == details.RoomId && timeSlot.Employee.Id == details.EmployeeId); }
private static Expression <Func <TherapySession, bool> > HasDetails(IBasicSessionDetails details) { return(therapySession => therapySession.PrimaryService.Type == details.PrimaryServiceType && therapySession.Chamber.Id == details.ChamberId && therapySession.Room.Id == details.RoomId && therapySession.Employee.Id == details.EmployeeId); }
public static ISpecification <TherapySession> ForOverlaps(IBasicSessionDetails details, DayOfWeek dayOfWeek, TimeSpan timeOfDay, TimeSpan duration) { // Issue: this is not working code , DateTime.DayOfWeek (for datetime-column) cannot be translated to sql // and will throw exception var endTime = timeOfDay + duration; return(new Specification <TherapySession>(HasDetails(details)) .Where(therapySession => therapySession.DateTime.DayOfWeek == dayOfWeek) .Where(therapySession => therapySession.DateTime.TimeOfDay < endTime && timeOfDay < therapySession.DateTime.TimeOfDay + therapySession.Duration)); }
public static ISpecification <TimeSlot> ForOverlaps( IBasicSessionDetails details, DayOfWeek dayOfWeek, TimeSpan timeOfDay, TimeSpan duration, DateTime startDate, DateTime?endDate = null, params Guid[] exceptedTimeSlotIds) { var timeSlotItemTime = timeOfDay + duration; return(new TimeSlotSpecification(HasDetails(details)) .Where(timeSlot => timeSlot.Items.Any(item => item.DayOfWeek == dayOfWeek && item.TimeOfDay < timeSlotItemTime && timeOfDay < item.TimeOfDay + timeSlot.Duration)) .Where(timeSlot => !exceptedTimeSlotIds.Contains(timeSlot.Id)) .Where(WithinDateRange(startDate, endDate ?? DateTime.MaxValue))); }