private IEnumerable <RoomRenovationDto> BasicRenovationSearch(SchedulingDto dto) { List <RoomRenovationDto> appointments = new List <RoomRenovationDto>(); List <Shift> availableShiftsSource = new List <Shift>(); IEnumerable <Shift> shiftsForSourceRoom = _shiftWrapper.Repository.GetShiftsByRoomID(dto.SourceRoomId); foreach (Shift shift in shiftsForSourceRoom) { List <Shift> shiftList = new List <Shift>(); shiftList.Add(shift); IEnumerable <RecommendationDto> recommendationsSourceRoom = FindRecommendationsInShifts(shiftList, MaximumAppointmentsInShift); if (recommendationsSourceRoom.Count() == MaximumAppointmentsInShift) { availableShiftsSource.Add(shift); } } foreach (Shift shift in availableShiftsSource) { RoomRenovationDto roomRenovationDto = new RoomRenovationDto() { SourceRoomId = dto.SourceRoomId, DestinationRoomId = dto.DestinationRoomId, TimeInterval = shift.TimeInterval }; appointments.Add(roomRenovationDto); } return(appointments); }
private IEnumerable <RoomRenovationDto> ComplexRenovationSearch(SchedulingDto dto) { List <RoomRenovationDto> appointments = new List <RoomRenovationDto>(); List <Shift> availableShiftsSource = new List <Shift>(); List <Shift> availableShiftsDestination = new List <Shift>(); IEnumerable <Shift> shiftsForDestinationRoom = _shiftWrapper.Repository.GetShiftsByRoomID(dto.DestinationRoomId); IEnumerable <Shift> shiftsForSourceRoom = _shiftWrapper.Repository.GetShiftsByRoomID(dto.SourceRoomId); foreach (Shift shift in shiftsForSourceRoom) { List <Shift> shiftList = new List <Shift>(); shiftList.Add(shift); IEnumerable <RecommendationDto> recommendationsSourceRoom = FindRecommendationsInShifts(shiftList, MaximumAppointmentsInShift); if (recommendationsSourceRoom.Count() == MaximumAppointmentsInShift) { availableShiftsSource.Add(shift); } } foreach (Shift shift in shiftsForDestinationRoom) { List <Shift> shiftList = new List <Shift>(); shiftList.Add(shift); IEnumerable <RecommendationDto> recommendationsDestinationRoom = FindRecommendationsInShifts(shiftList, MaximumAppointmentsInShift); if (recommendationsDestinationRoom.Count() == MaximumAppointmentsInShift) { availableShiftsDestination.Add(shift); } } List <TimeInterval> availableTimeIntervals = new List <TimeInterval>(); foreach (Shift shiftSource in availableShiftsSource) { foreach (Shift shiftDest in availableShiftsDestination) { if (shiftDest.TimeInterval.Start.Date == shiftSource.TimeInterval.Start.Date && shiftDest.TimeInterval.End.Date == shiftSource.TimeInterval.End.Date) { availableTimeIntervals.Add(shiftDest.TimeInterval); } } } foreach (TimeInterval timeInterval in availableTimeIntervals) { RoomRenovationDto roomRenovationDto = new RoomRenovationDto() { SourceRoomId = dto.SourceRoomId, DestinationRoomId = dto.DestinationRoomId, TimeInterval = timeInterval }; appointments.Add(roomRenovationDto); } return(appointments); }