public async Task <List <Flight> > GetFlightsBySearch(string origin, string destination, DateTime departure, int peopleCount) { var flights = await _repository.GetAllFlights(); List <Flight> retVal = new List <Flight>(); if (flights != null) { foreach (Flight f in flights) { if (f.DepartureLocation.Name.ToLower().Equals(origin.ToLower()) && f.ArrivalLocation.Name.ToLower().Equals(destination.ToLower()) && f.Departure >= departure) { var aeroplane = await _aeroplaneRepository.GetAeroplane(f.AeroplaneId); if (aeroplane != null && aeroplane.Seats != null && aeroplane.Seats.DeletedSeats != null && (aeroplane.Seats.SeatCount - aeroplane.Seats.DeletedSeats.Count) >= peopleCount) { retVal.Add(f); } } } } return(retVal); }
public async Task <Aeroplane> GetAeroplane(long id) { return(await _repository.GetAeroplane(id)); }