Exemple #1
0
		public Flight(
            string flightNumber, Airport departureAirport, Airport destinationAirport, Aircraft aircraft, DateTime departureTime)
            : this (Transient, flightNumber, departureAirport, destinationAirport, aircraft, departureTime, new Cabin[] {})
		{
            foreach (Cabin cabin in aircraft.Cabins)
            {
                this.cabins.Add(cabin.CabinClass, new Cabin(cabin));
            }
			CalculateSeatPlan();
        }
Exemple #2
0
 public Flight(
     long id, string flightNumber, Airport departureAirport, Airport destinationAirport, Aircraft aircraft, DateTime departureTime, params Cabin[] cabins) : base(id)
 {
     this.flightNumber = flightNumber;
     this.departureAirport = departureAirport;
     this.destinationAirport = destinationAirport;
     this.aircraft = aircraft;
     this.departureTime = departureTime;
     foreach (Cabin cabin in cabins)
     {
         this.cabins.Add(cabin.CabinClass, cabin);
     }
     CalculateSeatPlan();
 }
Exemple #3
0
 private Airport GetNothingAirport()
 {
     if (this.nothingAirport == null)
     {
         this.nothingAirport = new Airport(0, string.Empty, string.Empty, "-- " + GetMessage("selectAirport") + " --");
     }
     return this.nothingAirport;
 }
		/// <summary>
		/// Adds an <see cref="SpringAir.Domain.Airport"/> to the end of this collection.
		/// </summary>
		/// <param name="value">
		/// The <see cref="SpringAir.Domain.Airport"/> to be added to the end of the collection.
		/// </param>
		/// <returns>
		/// The index at which the <see cref="SpringAir.Domain.Airport"/> has been added.
		/// </returns>
		public int Add(Airport value)
		{
			return base.List.Add(value);
		}
Exemple #5
0
        public FlightCollection GetFlights(Airport origin, Airport destination, DateTime departureDate)
        {
            #region Sanity Checks
            AssertUtils.ArgumentNotNull(origin, "origin");
            AssertUtils.ArgumentNotNull(destination, "destination");
            #endregion

            FlightCollection flights = new FlightCollection();
            
            
            IDbParametersBuilder builder = new DbParametersBuilder(DbProvider);
            builder.Create().Name("departureDate").Type(DbType.Date).Value(departureDate);
            builder.Create().Name("departureAirport").Type(DbType.Int32).Value(origin.Id);
            builder.Create().Name("destinationAirport").Type(DbType.Int32).Value(destination.Id);

#if NET_2_0            
            AdoTemplate.QueryWithRowCallbackDelegate(CommandType.Text, FlightsQuery, 
                                                 delegate(IDataReader dataReader)
                                                 {
                                                     int flightId = dataReader.GetInt32(0);
                                                     string flightNumber = dataReader.GetString(1);
                                                     Aircraft aircraft = aircraftDao.GetAircraft(dataReader.GetInt32(2));

                                                     //TODO: Load cabins from the database
                                                     Cabin[] cabins = aircraft.Cabins;

                                                     Flight flight = new Flight(flightId, flightNumber, origin, destination, aircraft, departureDate, cabins);
                                                     flights.Add(flight); 
                                                 }, 
                                             
                                             
                                             builder.GetParameters());
#else
      AdoTemplate.QueryWithRowCallback(CommandType.Text, FlightsQuery,
                                        new FlightRowCallback(flights, aircraftDao, origin,destination,departureDate ),
                                        builder.GetParameters());      
#endif
            
            
            /*
            IDbCommand command = GetCommand(FlightsQuery);
            using(new ConnectionManager(command.Connection))
            {
                SetFlightQueryParameters(command, departureDate, origin.Id, destination.Id);
                using (SqlDataReader reader = (SqlDataReader) command.ExecuteReader())
                {
                    while(reader.Read())
                    {
                        int flightId = reader.GetInt32(0);
                        string flightNumber = reader.GetString(1);
                        Aircraft aircraft = aircraftDao.GetAircraft(reader.GetInt32(2));

                        //TODO: Load cabins from the database
                        Cabin[] cabins = aircraft.Cabins;

                        Flight flight = new Flight(flightId, flightNumber, origin, destination, aircraft, departureDate, cabins);
                        flights.Add(flight);
                    }
                }
            }
             */
            return flights;
        }
Exemple #6
0
 public FlightRowCallback(FlightCollection flights, IAircraftDao aircraftDao, 
                          Airport origin, Airport destination, DateTime departureDate)
 {
     this.flights = flights;
     this.aircraftDao = aircraftDao;
     this.origin = origin;
     this.destination = destination;
     this.departureDate = departureDate;
 }
		private FlightCollection GetFlights(Airport origin, Airport destination, DateTime departureDate)
		{
			return this.flightDao.GetFlights(origin, destination, departureDate);
		}