public bool checkIfAvailable(int iRouteID, DateTime dtFlight, int numSeats) { FlightDAOFactory flightDAL = FlightDAOFactory.getInstance(); //get the capacity of the flight for the route Route r = flightDAL.getFlightDALInstance().getRouteDetails(iRouteID); if (r == null) { return(false); } int capacity = r.Flight.Capacity; //get the list of reservations done for the route on the given date List <Reservation> lstReserve = flightDAL.getFlightDALInstance().getAllReservationsForDateOnRoute(iRouteID, dtFlight); if (lstReserve == null) { Console.WriteLine("No tickets booked yet for the flight on route - {0}", iRouteID); return(true); } int totalCount = 0; foreach (Reservation res in lstReserve) { totalCount += res.Passengers.Count(); } if ((capacity - totalCount) < numSeats) { return(false); } return(true); }
public List <Flight_DAL.Route> getFlightsBetweenCities(string startCityCode, string destCityCode) { lock (this) { FlightDAOFactory flightDAL = FlightDAOFactory.getInstance(); return(flightDAL.getFlightDALInstance().getAllRoutesBetweenCities(startCityCode, destCityCode)); } }
public List <Destination> getAllDestinations() { FlightDAOFactory flightDAL = FlightDAOFactory.getInstance(); try { return(flightDAL.getFlightDALInstance().getAllDestinations()); } catch (FlightException f) { Console.WriteLine(f.Message); throw f; } }