private async Task <dto.BookingUpdateResponseData> CancelFlight(int journeyIndex) { var booking = await _sessionBag.Booking(); var flightsCancelRequestData = new CancelRequestData { CancelBy = CancelBy.Journey, CancelJourney = new CancelJourney { CancelJourneyRequest = new CancelJourneyRequest { Journeys = new[] { Mapper.Map <Journey>(booking.Journeys[journeyIndex]) } } } }; var cancelResponse = await _client.CancelAsync(new CancelRequest { ContractVersion = _navApiContractVer, MessageContractVersion = _navMsgContractVer, Signature = await _sessionBag.Signature(), EnableExceptionStackTrace = false, CancelRequestData = flightsCancelRequestData }); await _bookingService.GetSessionBooking(true); return(Mapper.Map <dto.BookingUpdateResponseData>(cancelResponse.BookingUpdateResponseData)); }
public void CancelBooking(Booking booking) { CancelRequest cancelrequest = new CancelRequest(); cancelrequest.Signature = signature; CancelRequestData cancelrequestdata = new CancelRequestData(); cancelrequest.CancelRequestData = cancelrequestdata; cancelrequestdata.CancelBy = CancelBy.Journey; CancelJourney canceljourney = new CancelJourney(); cancelrequestdata.CancelJourney = canceljourney; CancelJourneyRequest canceljourneyrequest = new CancelJourneyRequest(); canceljourney.CancelJourneyRequest = canceljourneyrequest; //Journey[] journeys = new Journey[1]; //journeys[0] = new Journey(); //journeys[0].Segments = new Segment[1];//here i am assuming this is a direct journey with one segment //journeys[0].Segments[0] = new Segment(); //journeys[0].Segments[0].ActionStatusCode = booking.Journeys[0].Segments[0].ActionStatusCode; //journeys[0].Segments[0].DepartureStation = booking.Journeys[0].Segments[0].DepartureStation; //journeys[0].Segments[0].ArrivalStation = booking.Journeys[0].Segments[0].ArrivalStation; //journeys[0].Segments[0].STD = booking.Journeys[0].Segments[0].STD; //journeys[0].Segments[0].STA = booking.Journeys[0].Segments[0].STA; //journeys[0].Segments[0].FlightDesignator = booking.Journeys[0].Segments[0].FlightDesignator;//flight designator means carrier code canceljourneyrequest.Journeys = new Journey[1]; canceljourneyrequest.Journeys[0] = new Journey(); canceljourneyrequest.Journeys[0].Segments = new Segment[booking.Journeys[0].Segments.Length]; for (int i = 0; i < booking.Journeys[0].Segments.Length; i++) { canceljourneyrequest.Journeys[0].Segments[i] = new Segment(); canceljourneyrequest.Journeys[0].Segments[i].STA = booking.Journeys[0].Segments[i].STA; canceljourneyrequest.Journeys[0].Segments[i].STD = booking.Journeys[0].Segments[i].STD; canceljourneyrequest.Journeys[0].Segments[i].ArrivalStation = booking.Journeys[0].Segments[i].ArrivalStation; canceljourneyrequest.Journeys[0].Segments[i].DepartureStation = booking.Journeys[0].Segments[i].DepartureStation; canceljourneyrequest.Journeys[0].Segments[i].FlightDesignator = booking.Journeys[0].Segments[i].FlightDesignator; canceljourneyrequest.Journeys[0].Segments[i].Fares = new Fare[1]; canceljourneyrequest.Journeys[0].Segments[i].Fares[0] = new Fare(); canceljourneyrequest.Journeys[0].Segments[i].Fares[0].CarrierCode = booking.Journeys[0].Segments[i].Fares[0].CarrierCode; canceljourneyrequest.Journeys[0].Segments[i].PaxSSRs = new PaxSSR[0]; } canceljourneyrequest.Journeys = booking.Journeys; CancelResponse cancelresponse = clientapi.Cancel(cancelrequest); Console.WriteLine("Balance Due after cancellation: {0:C}", cancelresponse.BookingUpdateResponseData.Success.PNRAmount.BalanceDue); CommitRequest commitrequest = new CommitRequest(); commitrequest.BookingRequest = new CommitRequestData(); commitrequest.BookingRequest.Booking = new Booking(); commitrequest.BookingRequest.Booking.RecordLocator = booking.RecordLocator; commitrequest.BookingRequest.Booking.CurrencyCode = booking.CurrencyCode; commitrequest.BookingRequest.Booking.ReceivedBy = new ReceivedByInfo(); commitrequest.BookingRequest.Booking.ReceivedBy.ReceivedBy = "Michelle New"; commitrequest.Signature = signature; CommitResponse commitbookingresponse = clientapi.Commit(commitrequest); }
public async Task <dto.CancelResponse> CancelSSR(dto.CancelSSRRequest cancelSSRRequest) { var signature = await _sessionBag.Signature(); var data = cancelSSRRequest.SSRRequestData; var journeySegmentLegIndexes = new List <Tuple <int, List <Tuple <int, int[]> > > > { new Tuple <int, List <Tuple <int, int[]> > >(data.JourneyIndex, new List <Tuple <int, int[]> > { new Tuple <int, int[]>(data.SegmentIndex, data.LegIndex.HasValue ? new[] { data.LegIndex.Value } : null) }) }; var ssrs = await _resourcesService.GetSSRList(await _sessionBag.CultureCode()); var ssr = Array.Find(ssrs.SSRList, p => p.SSRCode == data.SSRCode); var existingPaxSsrs = Array.FindAll((await _sessionBag.Booking()).Journeys[data.JourneyIndex].Segments[data.SegmentIndex].PaxSSRs, p => p.SSRCode == data.SSRCode && p.PassengerNumber == data.PaxNumber && (data.Note != null ? data.Note == p.Note : true)); var ssrNumbersAll = existingPaxSsrs.Select(p => p.SSRNumber).ToList(); var ssrNumbersToCancel = ssrNumbersAll.GetRange(ssrNumbersAll.Count() - data.SSRCount, data.SSRCount); var ssrNumbersToCancelDict = new Dictionary <int, List <short> >(); ssrNumbersToCancelDict.Add(data.PaxNumber, ssrNumbersToCancel.ToList()); var navJourneys = Mapper.Map <Journey[]>((await _sessionBag.Booking()).Journeys); var segmentSSRRequests = NewskiesHelper.CreateSegmentSSRRequests(navJourneys.ToList(), Mapper.Map <SSR>(ssr), new[] { data.PaxNumber }, data.SSRCount, journeySegmentLegIndexes, ssrNumbersToCancelDict, data.Note); var cancelRequestData = new CancelRequestData { CancelBy = CancelBy.SSR, CancelSSR = new CancelSSR { SSRRequest = new SSRRequest { CurrencyCode = (await _sessionBag.Booking()).CurrencyCode, SegmentSSRRequests = segmentSSRRequests.ToArray() } } }; var cancelSSRsResponse = await _client.CancelAsync(new CancelRequest { ContractVersion = _navApiContractVer, MessageContractVersion = _navMsgContractVer, Signature = signature, EnableExceptionStackTrace = false, CancelRequestData = cancelRequestData }); // _navApiContractVer, false, _navMsgContractVer, signature, cancelRequestData); return(Mapper.Map <dto.CancelResponse>(cancelSSRsResponse)); }
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); }