コード例 #1
0
        private async Task <SegmentSSRRequest[]> CreateSegmentSSRRequests(dto.SellJourneyByKeyRequestData sellJourneyByKeyRequestData)
        {
            var segmentSSRRequests = new List <SegmentSSRRequest>();
            var infantPaxCount     = Array.Find(sellJourneyByKeyRequestData.PaxTypeCounts,
                                                p => p.PaxTypeCode.Equals(Global.INFANT_CODE));

            if (infantPaxCount != null && infantPaxCount.PaxCount > 0)
            {
                var ssrs = await _resourcesService.GetSSRList(await _sessionBag.CultureCode());

                var infantSsr   = Array.Find(ssrs.SSRList, p => p.SSRCode == Global.INFANT_CODE);
                var sellKeyList = Mapper.Map <SellKeyList[]>(sellJourneyByKeyRequestData.JourneySellKeys);
                var journeys    = NewskiesHelper.GetJourneysFromSellKeys(sellKeyList).ToList();
                var paxNumbers  = new List <int>();
                for (var i = 0; i < infantPaxCount.PaxCount; i++)
                {
                    paxNumbers.Add(i);
                }
                var journeySegmentLegIndexes = new List <Tuple <int, List <Tuple <int, int[]> > > >();
                for (var j = 0; j < journeys.Count(); j++)
                {
                    var segmentLegIndexes = new List <Tuple <int, int[]> >();
                    for (var s = 0; s < journeys[j].Segments.Length; s++)
                    {
                        segmentLegIndexes.Add(new Tuple <int, int[]>(s, null));
                    }
                    journeySegmentLegIndexes.Add(new Tuple <int, List <Tuple <int, int[]> > >(j, segmentLegIndexes));
                }
                segmentSSRRequests = NewskiesHelper.CreateSegmentSSRRequests(
                    journeys, Mapper.Map <SSR>(infantSsr), paxNumbers.ToArray(), 1, journeySegmentLegIndexes);
            }
            return(segmentSSRRequests.ToArray());
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        public async Task <dto.SellResponse> SellSSR(dto.SellSSRRequest sellSSRRequest)
        {
            var data = sellSSRRequest.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 signature = await _sessionBag.Signature();

            var ssrs = await _resourcesService.GetSSRList(await _sessionBag.CultureCode());

            var ssr                = ssrs.SSRList.FirstOrDefault(p => p.SSRCode == data.SSRCode);//Array.Find(ssrs.SSRList, p => p.SSRCode == data.SSRCode);
            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, note: data.Note);
            var ssrSellRequestData = new SellRequestData
            {
                SellBy  = SellBy.SSR,
                SellSSR = new SellSSR
                {
                    SSRRequest = new SSRRequest
                    {
                        CurrencyCode       = (await _sessionBag.Booking()).CurrencyCode,
                        SegmentSSRRequests = segmentSSRRequests.ToArray()
                    }
                }
            };
            var sellSSRsResponse = await _client.SellAsync(new SellRequest
            {
                ContractVersion        = _navApiContractVer,
                MessageContractVersion = _navMsgContractVer,
                Signature = signature,
                EnableExceptionStackTrace = false,
                SellRequestData           = ssrSellRequestData
            });

            //_navApiContractVer, false, _navMsgContractVer, signature, ssrSellRequestData);
            return(Mapper.Map <dto.SellResponse>(sellSSRsResponse));
        }