public bool CreateBooking(Booking booking) { //Steps: //1. Create Booking Id //2. Create Air Pnr //3. Save Flight //4. Save FlightFare //5. Save Passengers //6. Save PaymentInfo var result = true; try { int bookingId; var db = new MySqlDatabase(DbConfiguration.ReservationDB); var cmd = CommandBuilder.BuildCreateBookingCommand(booking.BookingType, booking.AccountId, booking.TravelDate, booking.TravelEndDate, booking.PassengerCount, booking.BookingStatus, db.Connection); db.ExecuteNonQuery(cmd, "outBookingId", out bookingId); if (bookingId != 0) { booking.BookingId = bookingId.ToString(); if (booking.FlightBookings != null) result &= booking.FlightBookings.TrueForAll(x => SaveAirPnr(bookingId, x)); if (result && booking.Charges != null) result &= booking.Charges.TrueForAll(x => SaveCharge(bookingId, x)); return result; } } catch (Exception ex) { DBExceptionLogger.LogException(ex, Source, "CreateBooking", Severity.Critical); return false; } return false; }
public bool Book(string requestId, AirItinerary airItinerary, List<Passenger> passengers, List<Charge> charges, Account account, out string errorMessage, out Booking booking) { errorMessage = string.Empty; var mode = ConfigSettings.SupplierMode; booking = null; try { var supplierInfo = SupplierDataProviderFactory.GetSupplierDataProvider().GetSupplier(airItinerary.Provider, mode); var supplier = GetSupplier(supplierInfo); if (supplier != null) { List<string> ticketNumbers; string pnr = supplier.Book(airItinerary, passengers, charges, account, out ticketNumbers); if (!string.IsNullOrEmpty(pnr)) { var bookingDataProvider = BookingDataProviderFactory.CreateBookingDataProvider(); booking = CreateBooking(airItinerary, passengers, charges, pnr, requestId, account.AccountId, ticketNumbers); booking.TicketNumbers = ticketNumbers; return bookingDataProvider.CreateBooking(booking); } } } catch (Exception exception) { errorMessage = exception.Message; Logger.LogException(exception, "FlightProvider", "Price", Severity.Major); } return false; }
public bool Book(string requestId, AirItinerary airItinerary, List<Passenger> passengers, List<Charge> charges, Account account, out string errorMessage, out Booking booking) { errorMessage = null; booking = null; return true; }