Example #1
0
        public void TypeSafeAdd()
        {
            FlightCollection flights = new FlightCollection();

            flights.Add(new Flight());
            flights.Add(new Flight());
            Assert.AreEqual(2, flights.Count);
        }
		public void TypeSafeAdd()
		{
			FlightCollection flights = new FlightCollection();
			flights.Add(new Flight());
			flights.Add(new Flight());
            Assert.AreEqual(2, flights.Count);

		}
 public void TypeSafeIndexer()
 {
     FlightCollection flights = new FlightCollection();
     Flight firstFlight = new Flight();
     firstFlight.FlightNumber = "1";
     flights.Add(firstFlight);
     flights.Add(new Flight());
     Flight f1 = flights[0];
     Assert.IsNotNull(f1);
     Assert.AreEqual("1", f1.FlightNumber);
 }
Example #4
0
        public void TypeSafeIndexer()
        {
            FlightCollection flights     = new FlightCollection();
            Flight           firstFlight = new Flight();

            firstFlight.FlightNumber = "1";
            flights.Add(firstFlight);
            flights.Add(new Flight());
            Flight f1 = flights[0];

            Assert.IsNotNull(f1);
            Assert.AreEqual("1", f1.FlightNumber);
        }
Example #5
0
 /// <summary>
 /// Creates a new instance of the <see cref="SpringAir.Domain.Itinerary"/>
 /// class.
 /// </summary>
 /// <remarks>
 /// <p>
 /// Use this constructor for a one way journey.
 /// </p>
 /// </remarks>
 /// <param name="id">
 /// The number that uniquely identifies this instance.
 /// </param>
 /// <param name="price">Price for this itinerary.</param>
 /// <param name="flights">
 /// Flights for this itinerary.
 /// </param>
 public Itinerary(long id, decimal price, FlightCollection flights) : base(id)
 {
     this.price   = price;
     this.flights = flights;
 }
Example #6
0
 /// <summary>
 /// Creates a new instance of the <see cref="SpringAir.Domain.Itinerary"/>
 /// class.
 /// </summary>
 /// <remarks>
 /// <p>
 /// Use this constructor for a one way journey.
 /// </p>
 /// </remarks>
 /// <param name="flights">
 /// Flights for this itinerary.
 /// </param>
 public Itinerary(FlightCollection flights)
     : this(Transient, 0.0M, flights)
 {
 }
Example #7
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;
 }
		/// <summary>
		/// Creates a new instance of the
		/// <see cref="SpringAir.Domain.FlightSuggestions"/> class.
		/// </summary>
		/// <param name="outboundFlights">
		/// The collection of outbound <see cref="SpringAir.Domain.Flight"/> objects.
		/// </param>
		public FlightSuggestions(FlightCollection outboundFlights)
			: this(outboundFlights, new FlightCollection())
		{
		}
		private static FlightCollection FlightsNotNull(FlightCollection flights)
		{
			return flights == null ? new FlightCollection() : flights;
		}
Example #10
0
 private static FlightCollection FlightsNotNull(FlightCollection flights)
 {
     return(flights == null ? new FlightCollection() : flights);
 }
Example #11
0
 private Flight GetFlight(FlightCollection flights, int flightIndex)
 {
     return(flights[flightIndex]);
 }
Example #12
0
 /// <summary>
 /// Creates a new instance of the <see cref="SpringAir.Domain.Itinerary"/>
 /// class.
 /// </summary>
 /// <remarks>
 /// <p>
 /// Use this constructor for a one way journey.
 /// </p>
 /// </remarks>
 /// <param name="id">
 /// The number that uniquely identifies this instance.
 /// </param>
 /// <param name="price">Price for this itinerary.</param>
 /// <param name="flights">
 /// Flights for this itinerary.
 /// </param>
 public Itinerary(long id, decimal price, FlightCollection flights) : base(id)
 {
     this.price = price;
     this.flights = flights;
 }
Example #13
0
 /// <summary>
 /// Creates a new instance of the <see cref="SpringAir.Domain.Itinerary"/>
 /// class.
 /// </summary>
 /// <remarks>
 /// <p>
 /// Use this constructor for a one way journey.
 /// </p>
 /// </remarks>
 /// <param name="flights">
 /// Flights for this itinerary.
 /// </param>
 public Itinerary(FlightCollection flights)
     : this(Transient, 0.0M, flights)
 {
 }
Example #14
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;
        }
		private FlightCollection GetFlightsToBook()
		{
			FlightCollection flightsToBook = new FlightCollection();
			Flight outboundFlight = this.flights.GetOutboundFlight(outboundFlightIndex);
			flightsToBook.Add(outboundFlight);
			if (HasReturnFlight)
			{
				Flight returnFlight = this.flights.GetReturnFlight(returnFlightIndex);
				flightsToBook.Add(returnFlight);
			}
			return flightsToBook;
		}
Example #16
0
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="SpringAir.Domain.FlightSuggestions"/> class.
 public FlightSuggestions()
 {
     this.outboundFlights = new FlightCollection();
     this.returnFlights   = new FlightCollection();
 }
Example #17
0
		private Flight GetFlight(FlightCollection flights, int flightIndex) 
		{
			return flights[flightIndex];
		}
Example #18
0
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="SpringAir.Domain.FlightSuggestions"/> class.
 /// </summary>
 /// <param name="outboundFlights">
 /// The collection of outbound <see cref="SpringAir.Domain.Flight"/> objects.
 /// </param>
 public FlightSuggestions(FlightCollection outboundFlights)
     : this(outboundFlights, new FlightCollection())
 {
 }
Example #19
0
		/// <summary>
		/// Creates a new instance of the
		/// <see cref="SpringAir.Domain.FlightSuggestions"/> class.
		public FlightSuggestions()
		{
			this.outboundFlights = new FlightCollection();
			this.returnFlights = new FlightCollection();
		}
Example #20
0
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="SpringAir.Domain.FlightSuggestions"/> class.
 /// </summary>
 /// <param name="outboundFlights">
 /// The collection of outbound <see cref="SpringAir.Domain.Flight"/> objects.
 /// </param>
 /// <param name="returnFlights">
 /// The collection of return <see cref="SpringAir.Domain.Flight"/> objects.
 /// </param>
 public FlightSuggestions(FlightCollection outboundFlights, FlightCollection returnFlights)
 {
     this.outboundFlights = FlightsNotNull(outboundFlights);
     this.returnFlights   = FlightsNotNull(returnFlights);
 }
Example #21
0
		/// <summary>
		/// Creates a new instance of the
		/// <see cref="SpringAir.Domain.FlightSuggestions"/> class.
		/// </summary>
		/// <param name="outboundFlights">
		/// The collection of outbound <see cref="SpringAir.Domain.Flight"/> objects.
		/// </param>
		/// <param name="returnFlights">
		/// The collection of return <see cref="SpringAir.Domain.Flight"/> objects.
		/// </param>
		public FlightSuggestions(FlightCollection outboundFlights, FlightCollection returnFlights)
		{
			this.outboundFlights = FlightsNotNull(outboundFlights);
			this.returnFlights = FlightsNotNull(returnFlights);
		}
		public FlightSuggestions SuggestFlights([Validated("tripValidator")] Trip trip)
		{
			#region Sanity Check

			if (trip == null)
			{
				throw new ArgumentNullException("trip", "The 'trip' argument is required.");
			}

			#endregion

			Aircraft outboundAircraft, returnAircraft;
			bool transAtlantic = trip.StartingFrom.AirportCode == "LHR" || trip.ReturningFrom.AirportCode == "LHR";
			if (transAtlantic)
			{
				outboundAircraft = aircraftDao.GetAircraft(2);
				returnAircraft = aircraftDao.GetAircraft(2);
			}
			else
			{
				outboundAircraft = aircraftDao.GetAircraft(1);
				returnAircraft = aircraftDao.GetAircraft(3);
			}
			Airport from = airportDao.GetAirport(trip.StartingFrom.AirportCode);
			Airport to = airportDao.GetAirport(trip.ReturningFrom.AirportCode);

			FlightCollection outboundFlights = new FlightCollection();
			outboundFlights.Add(new Flight("UA 0123", from, to, outboundAircraft, trip.StartingFrom.Date.AddHours(6.5)));
			outboundFlights.Add(new Flight("AA 2367", from, to, outboundAircraft, trip.StartingFrom.Date.AddHours(10)));
			outboundFlights.Add(new Flight("SW 6534", from, to, outboundAircraft, trip.StartingFrom.Date.AddHours(15.75)));
			outboundFlights.Add(new Flight("CO 0054", from, to, outboundAircraft, trip.StartingFrom.Date.AddHours(19.25)));

			FlightCollection returnFlights = new FlightCollection();
			returnFlights.Add(new Flight("CO 0112", to, from, returnAircraft, trip.ReturningFrom.Date.AddHours(9)));
			returnFlights.Add(new Flight("UA 0230", to, from, returnAircraft, trip.ReturningFrom.Date.AddHours(12.3)));
			returnFlights.Add(new Flight("AA 2234", to, from, returnAircraft, trip.ReturningFrom.Date.AddHours(21.5)));

			if (trip.Mode == TripMode.RoundTrip)
			{
				return new FlightSuggestions(outboundFlights, returnFlights);
			}
			else
			{
				return new FlightSuggestions(outboundFlights, NoSuggestions);
			}
		}