コード例 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Flight_Leg EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToFlight_Leg(Flight_Leg flight_Leg)
 {
     base.AddObject("Flight_Leg", flight_Leg);
 }
コード例 #2
0
 /// <summary>
 /// Create a new Flight_Leg object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="flightNumber">Initial value of the FlightNumber property.</param>
 /// <param name="availableSeats">Initial value of the AvailableSeats property.</param>
 /// <param name="isCancelled">Initial value of the IsCancelled property.</param>
 /// <param name="scheduledDepartureTime">Initial value of the ScheduledDepartureTime property.</param>
 /// <param name="scheduledArrivalTime">Initial value of the ScheduledArrivalTime property.</param>
 /// <param name="isRescheduled">Initial value of the IsRescheduled property.</param>
 /// <param name="fare">Initial value of the Fare property.</param>
 /// <param name="flight_Route_Id">Initial value of the Flight_Route_Id property.</param>
 public static Flight_Leg CreateFlight_Leg(global::System.Int32 id, global::System.DateTime date, global::System.Int16 flightNumber, global::System.Int32 availableSeats, global::System.Boolean isCancelled, global::System.DateTime scheduledDepartureTime, global::System.DateTime scheduledArrivalTime, global::System.Boolean isRescheduled, global::System.Double fare, global::System.Int32 flight_Route_Id)
 {
     Flight_Leg flight_Leg = new Flight_Leg();
     flight_Leg.Id = id;
     flight_Leg.Date = date;
     flight_Leg.FlightNumber = flightNumber;
     flight_Leg.AvailableSeats = availableSeats;
     flight_Leg.IsCancelled = isCancelled;
     flight_Leg.ScheduledDepartureTime = scheduledDepartureTime;
     flight_Leg.ScheduledArrivalTime = scheduledArrivalTime;
     flight_Leg.IsRescheduled = isRescheduled;
     flight_Leg.Fare = fare;
     flight_Leg.Flight_Route_Id = flight_Route_Id;
     return flight_Leg;
 }
コード例 #3
0
        public void AddFlightLeg(FlightLeg flightLeg)
        {
            var newFlightLeg = new Flight_Leg();

            using (var dataContext = new Model1Container())
            {

                newFlightLeg.AvailableSeats = flightLeg.SelectedPlane.NoOfSeats;
                newFlightLeg.Date = flightLeg.TravelDate;
                newFlightLeg.Fare = 300;
                newFlightLeg.IsCancelled = false;
                newFlightLeg.IsRescheduled = false;
                newFlightLeg.Flight_Route_Id = flightLeg.SelectedRoute.Id;
                newFlightLeg.FlightNumber = (short)flightLeg.FlightNumber;
                newFlightLeg.ScheduledDepartureTime = flightLeg.ScheduledDepartureTime;
                newFlightLeg.ScheduledArrivalTime = flightLeg.ScheduledArrivalTime;

                dataContext.Flight_Leg.AddObject(newFlightLeg);
                //dataContext.AddToFlight_Leg(newFlightLeg);
                dataContext.SaveChanges();

                for (int row = 0; row < flightLeg.SelectedPlane.TotalRows; row++)
                {

                    for (int col = 0; col < flightLeg.SelectedPlane.TotalColumns; col++)
                    {
                        string seatNumber = "";
                        if (col == 0)
                        {
                            seatNumber = string.Format("{0}{1}", row+1, "A");
                        }
                        if (col == 1)
                        {
                            seatNumber = string.Format("{0}{1}", row + 1, "B");
                        }
                        if (col == 2)
                        {
                            seatNumber = string.Format("{0}{1}", row + 1, "C");
                        }
                        if (col == 3)
                        {
                            seatNumber = string.Format("{0}{1}", row + 1, "D");
                        }
                        if (col == 4)
                        {
                            seatNumber = string.Format("{0}{1}", row + 1, "E");
                        }
                        if (col == 5)
                        {
                            seatNumber = string.Format("{0}{1}", row + 1, "F");
                        }

                        dataContext.AddToFligt_Leg_Seat_Assignment(new Fligt_Leg_Seat_Assignment { SeatingClass = "Economy", Flight_Leg_FlightNumber=newFlightLeg.FlightNumber, SeatNumber = seatNumber, Flight_Leg_Id = newFlightLeg.Id, IsAvailable = true, SeatType = "Normal" });

                        //dataContext.AddToFligt_Leg_Seat_Assignment(new Fligt_Leg_Seat_Assignment { SeatingClass = "Economy", Flight_Leg_Id = newFlightLeg.Id,  SeatNumber = seatNumber, IsAvailable = true, SeatType = "Normal" });
                    }

                }
                dataContext.SaveChanges();
            }
        }