private int getNumSeatsAvailable(Route r, DateTime dtFlight)
        {
            int capacity = r.Flight.Capacity;
            //            Console.WriteLine("Flight capacity - {0}", capacity);

            //get the list of reservations done for the route - for a given date
            List<Reservation> lstReserve;
            lock (this)
            {
                lstReserve = myFlightBLL.getFlightBLLInstance().getAllReservationsForDateOnRoute(r.RouteID, dtFlight);
            }
            if (lstReserve == null)
                return capacity;

            int totalCount = 0;
            //get the reservations done for the date of flight
            foreach (Reservation rsv in lstReserve)
            {
                if (DateTime.Compare(rsv.FlightDate, dtFlight) == 0)
                    totalCount += rsv.Passengers.Count();
            }
            Console.WriteLine("Total reservations found - {0}", totalCount);

            return (capacity - totalCount);
        }
Ejemplo n.º 2
0
 public int saveRoute(Route r)
 {
     try
     {
         flightContext.AddToRoutes(r);
         return flightContext.SaveChanges();
     }
     catch (Exception )
     {
         throw new FlightException("Error saving the route record.... ");
     }
 }
Ejemplo n.º 3
0
 //Get Flight routes going to a given destination - for a range of dates
 //same as above, as we assume that the flights operate 7 days a week.
 public List<Route> getAllRoutesBetweenCitiesOnDates(string startCityCode, string destinationCode, DateTime start, DateTime end)
 {
     flightContext.ContextOptions.LazyLoadingEnabled = false;
     var rQuery = from r in flightContext.Routes
                  where r.StartCity.Equals(startCityCode) && (r.EndCity.Equals(destinationCode))
                  select r;
     if(rQuery == null) return null;
     if(rQuery.Count() == 0) return null;
     Route route;
     List<Route> lstRoute = new List<Route>();
     foreach(var ro in rQuery)
     {
         route = new Route();
         route.RouteID = ro.RouteID;
         route.FlightID = ro.FlightID;
         route.FlightTime = ro.FlightTime;
         route.StartCity = ro.StartCity;
         route.EndCity = ro.EndCity;
         route.AdultFare = ro.AdultFare;
         route.ChildFare = ro.ChildFare;
         //add the flight details
         route.Flight = ro.Flight;
         //add the destination
         route.Destination = ro.Destination;
         route.Destination1 = ro.Destination1;
         lstRoute.Add(route);
     }
     return lstRoute;
 }
Ejemplo n.º 4
0
 public List<Route> getAllRoutesBetweenCities(string startCity, string destCity)
 {
     var rQuery = from r in flightContext.Routes
                  where r.StartCity.Equals(startCity) && (r.EndCity.Equals(destCity))
                  select r;
     if (rQuery == null) return null;
     if (rQuery.Count() == 0) return null;
     Route route;
     List<Route> lstRoute = new List<Route>();
     foreach (var ro in rQuery)
     {
         route = new Route();
         route.RouteID = ro.RouteID;
         route.FlightID = ro.FlightID;
         route.FlightTime = ro.FlightTime;
         route.StartCity = ro.StartCity;
         route.EndCity = ro.EndCity;
         route.AdultFare = ro.AdultFare;
         route.ChildFare = ro.ChildFare;
         //add the flight details
         route.Flight = ro.Flight;
         //add the destination
         route.Destination = ro.Destination;
         route.Destination1 = ro.Destination1;
         //reservation details not added as it is based on the date.
         lstRoute.Add(route);
     }
     return lstRoute;
 }
Ejemplo n.º 5
0
 public List<Route> getAllRoutes()
 {
     var rQuery = from r in flightContext.Routes
                  select r;
     if (rQuery == null) return null;
     if (rQuery.Count() == 0) return null;
     Route route;
     List<Route> lstRoute = new List<Route>();
     foreach (var ro in rQuery)
     {
         route = new Route();
         route.RouteID = ro.RouteID;
         route.FlightID = ro.FlightID;
         route.FlightTime = ro.FlightTime;
         route.StartCity = ro.StartCity;
         route.EndCity = ro.EndCity;
         route.AdultFare = ro.AdultFare;
         route.ChildFare = ro.ChildFare;
         lstRoute.Add(route);
     }
     return lstRoute;
 }
 /// <summary>
 /// Create a new Route object.
 /// </summary>
 /// <param name="routeID">Initial value of the RouteID property.</param>
 /// <param name="flightID">Initial value of the FlightID property.</param>
 /// <param name="flightTime">Initial value of the FlightTime property.</param>
 /// <param name="startCity">Initial value of the StartCity property.</param>
 /// <param name="endCity">Initial value of the EndCity property.</param>
 /// <param name="adultFare">Initial value of the AdultFare property.</param>
 /// <param name="childFare">Initial value of the ChildFare property.</param>
 public static Route CreateRoute(global::System.Int32 routeID, global::System.String flightID, global::System.String flightTime, global::System.String startCity, global::System.String endCity, global::System.Single adultFare, global::System.Single childFare)
 {
     Route route = new Route();
     route.RouteID = routeID;
     route.FlightID = flightID;
     route.FlightTime = flightTime;
     route.StartCity = startCity;
     route.EndCity = endCity;
     route.AdultFare = adultFare;
     route.ChildFare = childFare;
     return route;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Routes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRoutes(Route route)
 {
     base.AddObject("Routes", route);
 }