Beispiel #1
0
        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 <HttpResponseMessage> GetAllFlights()
        {
            List <Flight> flights = await FlightRepository.GetAllFlights();

            if (flights.Count >= 0)
            {
                return(Request.CreateResponse <List <Flight> >(HttpStatusCode.OK, flights));
            }

            return(Request.CreateResponse(HttpStatusCode.NotFound, "While retrieving all flights, error occured!"));
        }
Beispiel #3
0
        public List <string> GetAllFlights()
        {
            var flights     = FlightRepository.GetAllFlights();
            var flightNames = new List <string>();

            foreach (var flight in flights)
            {
                flightNames.Add($"Flight {flight.Route.Airport} - {flight.Route.Airport1}. With Airline: {flight.Airline.Name}. Operated by {flight.Airline1}.");
            }

            return(flightNames);
        }