public async Task <IActionResult> CreateBookingInSession() { try { await _sessionBag.Initialise(); var sellResponse = await _flightsService.SellFlights(new dto.SellJourneyByKeyRequestData { CurrencyCode = "SAR", PaxTypeCounts = new dto.PaxTypeCount[] { new dto.PaxTypeCount { PaxCount = 1, PaxTypeCode = "ADT" } }, JourneySellKeys = new dto.SellKeyList[] { new dto.SellKeyList { FareSellKey = "0~A~~F3~ADEAL~1003~~1~1~NJEDRUH0010010~X", JourneySellKey = "F3~ 107~ ~~JED~02/10/2018 13:10~RUH~02/10/2018 14:45~~" } } }); var names = new dto.BookingName[] { new dto.BookingName { FirstName = "test", LastName = "test", Title = "MR" } }; var updateCOnt = await _contactsService.UpdateContacts(new dto.UpdateContactsRequestData { BookingContactList = new dto.BookingContact[] { new dto.BookingContact { AddressLine1 = "sdfsdf", City = "sdfsdf", CountryCode = "AU", CultureCode = "en-US", EmailAddress = "*****@*****.**", HomePhone = "234567890", PostalCode = "2343", ProvinceState = "VIC", Names = names } } }); var updatePax = await _passengersService.UpdatePassengers(new dto.UpdatePassengersRequestData { Passengers = new dto.Passenger[] { new dto.Passenger { Names = names, PassengerTravelDocuments = new dto.PassengerTravelDocument[] { new dto.PassengerTravelDocument { Names = names, DocNumber = "P12121212", DocTypeCode = "P", ExpirationDate = new DateTime(2020, 1, 1), Gender = dto.Enumerations.Gender.Male, IssuedByCode = "AU" } }, PassengerTypeInfo = new dto.PassengerTypeInfo { DOB = new DateTime(1985, 1, 1), PaxType = "ADT" }, PassengerInfo = new dto.PassengerInfo { Gender = dto.Enumerations.Gender.Male, Nationality = "US", ResidentCountry = "US" } } } }); var booking = await _bookingService.GetSessionBooking(true); return(new OkObjectResult(booking)); } catch (Exception e) { return(e.ErrorActionResult()); } }
public async Task <IActionResult> Post([FromBody] UpdatePassengersRequestData requestData) { return(new OkObjectResult(await _passengersService.UpdatePassengers(requestData))); }
public async Task <dto.SellResponse> SellFlights(dto.SellJourneyByKeyRequestData sellJourneyByKeyRequestData) { if (string.IsNullOrEmpty(await _sessionBag.Signature())) { await _userSessionService.AnonymousLogonUnique(); } var signature = await _sessionBag.Signature(); if (await _sessionBag.Booking() != null) { // cancel previously selected flights (if any) for New Bookings only var booking = await _bookingService.GetSessionBooking(); if (string.IsNullOrEmpty(booking.RecordLocator) && booking.Journeys != null && booking.Journeys.Length > 0 && booking.Passengers != null && booking.Passengers.Length > 0) { // totally clear booking if pax type counts are different if (!PaxCountsAreTheSame(booking, sellJourneyByKeyRequestData)) { await _bookingService.ClearStateBooking(); } // pax type counts are the same so just cancel the journeys else { var cancelData = new CancelRequestData { CancelBy = CancelBy.Journey, CancelJourney = new CancelJourney { CancelJourneyRequest = new CancelJourneyRequest { Journeys = Mapper.Map <Journey[]>(booking.Journeys.ToArray()) } } }; try { await _client.CancelAsync(new CancelRequest { ContractVersion = _navApiContractVer, MessageContractVersion = _navMsgContractVer, Signature = signature, EnableExceptionStackTrace = false, CancelRequestData = cancelData }); } catch { await _bookingService.ClearStateBooking(); } } } } var flightsSellRequestData = new SellRequestData { SellBy = SellBy.JourneyBySellKey, SellJourneyByKeyRequest = new SellJourneyByKeyRequest { SellJourneyByKeyRequestData = Mapper.Map <SellJourneyByKeyRequestData>(sellJourneyByKeyRequestData), } }; var stopWatch = _perfLogSettings.EnableNavApiLogging ? Stopwatch.StartNew() : null; var sellFlightsResponse = await _client.SellAsync(new SellRequest { ContractVersion = _navApiContractVer, MessageContractVersion = _navMsgContractVer, Signature = signature, EnableExceptionStackTrace = false, SellRequestData = flightsSellRequestData }); //_navApiContractVer, false, _navMsgContractVer, //signature, flightsSellRequestData); if (_perfLogSettings.EnableNavApiLogging && stopWatch != null) { stopWatch.Stop(); var msecs = stopWatch.ElapsedMilliseconds; _logger.WriteTimedLog(msecs, "BookingManager.SellAsync" + "|" + signature); } var returnResponse = new dto.SellResponse(); // Sell infant SSR var infantPaxCount = Array.Find(sellJourneyByKeyRequestData.PaxTypeCounts, p => p.PaxTypeCode == Global.INFANT_CODE); if (infantPaxCount != null && infantPaxCount.PaxCount > 0) { var infantSegmentSSRRequests = await CreateSegmentSSRRequests(sellJourneyByKeyRequestData); var infantSSRSellRequestData = new SellRequestData { SellBy = SellBy.SSR, SellSSR = new SellSSR { SSRRequest = new SSRRequest { CurrencyCode = sellJourneyByKeyRequestData.CurrencyCode, SegmentSSRRequests = infantSegmentSSRRequests } } }; var stopWatch2 = _perfLogSettings.EnableNavApiLogging ? Stopwatch.StartNew() : null; var sellSSRsResponse = await _client.SellAsync(new SellRequest { ContractVersion = _navApiContractVer, MessageContractVersion = _navMsgContractVer, Signature = signature, EnableExceptionStackTrace = false, SellRequestData = infantSSRSellRequestData }); //_navApiContractVer, false, _navMsgContractVer, //signature, infantSSRSellRequestData); if (_perfLogSettings.EnableNavApiLogging && stopWatch != null) { stopWatch2.Stop(); var msecs = stopWatch2.ElapsedMilliseconds; _logger.WriteTimedLog(msecs, "BookingManager.SellAsync(INF)" + "|" + signature); } returnResponse = Mapper.Map <dto.SellResponse>(sellSSRsResponse); } else { returnResponse = Mapper.Map <dto.SellResponse>(sellFlightsResponse); } var stateBooking = await _bookingService.GetSessionBooking(true); await _sessionBag.SetBooking(stateBooking); if (string.IsNullOrEmpty(stateBooking.RecordLocator)) { var paxesWithInfant = new List <dto.Passenger>(); foreach (var pax in (await _sessionBag.Booking()).Passengers.ToList().FindAll(p => p.PassengerFees.ToList().Find( f => f.FeeCode == Global.INFANT_CODE) != null)) { if (pax.Infant == null) { pax.Infant = new dto.PassengerInfant(); paxesWithInfant.Add(pax); } } if (paxesWithInfant.Count() > 0) { var updatePaxesWithInfantsResult = await _passengerService.UpdatePassengers( new dto.UpdatePassengersRequestData { Passengers = paxesWithInfant.ToArray() }); if (updatePaxesWithInfantsResult.Error != null) { throw new Exception(updatePaxesWithInfantsResult.Error.ErrorText); } await _sessionBag.SetBooking(await _bookingService.GetSessionBooking(true)); } } return(returnResponse); }