Beispiel #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());
        }
Beispiel #2
0
        public async Task <IActionResult> Get(string culture = null)
        {
            var stationListResponse = await _resourcesService.GetStationList(culture);

            var marketListResponse = await _resourcesService.GetMarketList();

            var cultureListResponse = await _resourcesService.GetCultureList();

            var currencyListResponse = await _resourcesService.GetCurrencyList();

            var paxTypeListResponse = await _resourcesService.GetPaxTypeList();

            var travelDocTypeListResponse = await _resourcesService.GetDocTypeList(culture);

            var feeListResponse = await _resourcesService.GetFeeList(culture);

            var ssrList = await _resourcesService.GetSSRList(culture);

            var titleList = await _resourcesService.GetTitleList(culture);

            var countryList = await _resourcesService.GetCountryList(culture);

            var paymentMethods = await _resourcesService.GetPaymentMethodsList(culture);

            var resources = new AllResourcesResponse
            {
                StationList       = stationListResponse.StationList,
                MarketList        = marketListResponse.MarketList,
                CultureList       = cultureListResponse.CultureList,
                CurrencyList      = currencyListResponse.CurrencyList,
                PaxTypeList       = paxTypeListResponse.PaxTypeList,
                FeeList           = feeListResponse.FeeList,
                DocTypeList       = travelDocTypeListResponse.DocTypeList,
                SSRList           = ssrList.SSRList,
                TitleList         = titleList.TitleList,
                CountryList       = countryList.CountryList,
                PaymentMethodList = paymentMethods.PaymentMethodList,
            };

            return(new OkObjectResult(resources));
        }
Beispiel #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));
        }