public async Task <IEnumerable <TimeSlot> > GetRestTimeSlotOfFlight(string startPointId, string endPointId, DateTime flightDate) { var timeSlotList = await _repository.GetTimeSlotByFlightDirection(startPointId, endPointId); var flightList = await _flightRepository.GetFlightBySearchData(startPointId, endPointId, flightDate); List <TimeSlot> timeSlots = new List <TimeSlot>(); if (timeSlotList != null && flightList != null) { foreach (var timeSlot in timeSlotList) { bool isContain = false; foreach (var flight in flightList) { if (flight.StartTime.TotalSeconds == timeSlot.StartTime.TotalSeconds) { isContain = true; break; } } if (!isContain) { timeSlots.Add(timeSlot); } } } else if (timeSlotList != null && flightList == null) { return(timeSlotList); } return(timeSlots); }