/// <summary> /// Create a new Ticket object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="passengerId">Initial value of the PassengerId property.</param> /// <param name="seatId">Initial value of the SeatId property.</param> /// <param name="pricePaid">Initial value of the PricePaid property.</param> /// <param name="mealId">Initial value of the MealId property.</param> /// <param name="ticketedTime">Initial value of the TicketedTime property.</param> /// <param name="isCancelled">Initial value of the IsCancelled property.</param> public static Ticket CreateTicket(global::System.Int32 id, global::System.Int32 passengerId, global::System.Int32 seatId, global::System.Double pricePaid, global::System.Int32 mealId, global::System.DateTime ticketedTime, global::System.Boolean isCancelled) { Ticket ticket = new Ticket(); ticket.Id = id; ticket.PassengerId = passengerId; ticket.SeatId = seatId; ticket.PricePaid = pricePaid; ticket.MealId = mealId; ticket.TicketedTime = ticketedTime; ticket.IsCancelled = isCancelled; return ticket; }
/// <summary> /// Deprecated Method for adding a new object to the Tickets EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTickets(Ticket ticket) { base.AddObject("Tickets", ticket); }
public void BookTicket(int customerId, ReservationTicket ticket) { using (var context = new Model1Container()) { if (ticket.MealId == 0) { ticket.MealId = 1; } var cusomter = context.Passengers.Where(p => p.Id == customerId).Single(); var ticket_table = new Ticket { IsCancelled = false, MealId = ticket.MealId, PricePaid = ticket.PricePaid, SeatId = ticket.SeatId, TicketedTime = DateTime.Now, PassengerId = customerId }; ticket_table.Meal_Preference = new Meal_Preference { Id = ticket.MealId, MealType = "Veg" }; cusomter.Tickets.Add(ticket_table); var seat = context.Fligt_Leg_Seat_Assignment.Where(p => p.Id == ticket.SeatId).Single(); seat.IsAvailable = false; var flightLeg = context.Flight_Leg.Where(p => p.Id == ticket.FlightLegId).Single(); flightLeg.AvailableSeats = flightLeg.AvailableSeats - 1; context.SaveChanges(); } }