public async Task <ActionResult <IEnumerable <FlightM> > > GetFlightSet() { var flightList = await _context.FlightSet.ToListAsync(); List <FlightM> listFlightM = new List <FlightM>(); foreach (Flight f in flightList) { FlightM fM = new FlightM(); fM.FlightNo = f.FlightNo; fM.Date = f.Date; fM.Departure = f.Departure; fM.Destination = f.Destination; listFlightM.Add(fM); } return(listFlightM); }
public async Task <ActionResult <IEnumerable <FlightM> > > GetFutureFlightsSet() { var flightList = await _context.FlightSet.ToListAsync(); List <FlightM> listFlightM = new List <FlightM>(); foreach (Flight f in flightList) { // do not return past flights if (f.Date >= DateTime.Now && !IsFlightFull(f)) { FlightM fM = new FlightM(); fM.FlightNo = f.FlightNo; fM.Date = f.Date; fM.Departure = f.Departure; fM.Destination = f.Destination; listFlightM.Add(fM); } } return(listFlightM); }
public async Task <ActionResult <FlightM> > GetFlight(int id) { var flight = await _context.FlightSet.FindAsync(id); var flightM = new FlightM(); if (flight == null) { return(NotFound()); } else { flightM.FlightNo = flight.FlightNo; flightM.Date = flight.Date; flightM.Departure = flight.Departure; flightM.Destination = flight.Destination; flightM.BasePrice = flight.BasePrice; } return(flightM); }