public PriceResponse Price(string sessionId, AirItinerary airItinerary, List<Charge> charges) { IFlightProvider flightProvider = FlightProviderFactory.GetFlightProvider(); var response = new PriceResponse(); if (airItinerary != null) { try { string errorMessage; decimal chargeAmount; if (flightProvider.Price(airItinerary.ToModel(), charges.ToModel(), out errorMessage, out chargeAmount)) { response.IsSuccess = true; response.DisplayChargeAmount = chargeAmount; response.Currency = airItinerary.AirFare.Currency; response.PaymentUrl = "testURL"; response.PaymentPostData = "testData"; } else { response.IsSuccess = false; response.ErrorMessage = errorMessage; } } catch (Exception exception) { response.IsSuccess = false; response.ErrorMessage = "Something is not quite right here. Please try again later."; Logger.LogException(exception, Source, "Price", Severity.Critical); } } return response; }
public BookResponse Book(string authenticationId, string sessionId, AirItinerary airItinerary, List<Passenger> passengers, List<Charge> charges) { IFlightProvider flightProvider = FlightProviderFactory.GetFlightProvider(); var response = new BookResponse(); var authenticationProvider = AuthenticationProviderFactory.GetAuthenticationProvider(); var accountId = authenticationProvider.GetAccountId(authenticationId); var accountProvider = AccountProviderFactory.GetAccountProvider(); ISessionProvider sessionProvider = SessionProviderFactory.GetSessionProvider(); string errorMessage; SessionData sessionData = sessionProvider.GetSession(authenticationId, sessionId, out errorMessage); if (!string.IsNullOrEmpty(accountId) && airItinerary != null && charges != null && charges.Count > 0) { try { Booking booking; errorMessage = string.Empty; if (flightProvider.Book(sessionData.Request.RequestId, airItinerary.ToModel(), passengers.ToModel(), charges.ToModel(), accountProvider.GetAccount(accountId), out errorMessage, out booking) && string.IsNullOrEmpty(errorMessage)) { response.IsSuccess = true; response.Charges = charges; response.Itinerary = airItinerary; response.Passengers = passengers; response.Pnr = booking.FlightBookings[0].Pnr; response.TicketNumbers = booking.TicketNumbers; } else { response.IsSuccess = false; response.ErrorMessage = errorMessage; } } catch (Exception exception) { response.IsSuccess = false; response.ErrorMessage = "Something is not quite right here. Please try again later."; Logger.LogException(exception, Source, "Book", Severity.Critical); } } if (!response.IsSuccess) { IEmailProvider emailProvider = EmailProviderFactory.GetEmailProvider(); emailProvider.SendBookingFailureNotificationEmail(sessionData.Request.RequestId, sessionId, response.ErrorMessage); } return response; }