Exemplo n.º 1
0
        public async Task <dto.FindAgentsResponse> FindAgent(dto.FindAgentRequestData findAgentRequestData)
        {
            var signature = !string.IsNullOrEmpty(await _sessionBag.Signature())
                    ? await _sessionBag.Signature()
                    : await _userSessionService.GetAnonymousSharedSignature();

            var mappedRequest = Mapper.Map <FindAgentRequestData>(findAgentRequestData);
            var response      = await _client.FindAgentsAsync(new FindAgentsRequest
            {
                ContractVersion        = _navApiContractVer,
                MessageContractVersion = _navMsgContractVer,
                Signature = signature,
                EnableExceptionStackTrace = false,
                FindAgentRequestData      = mappedRequest
            });

            return(Mapper.Map <dto.FindAgentsResponse>(response));
        }
Exemplo n.º 2
0
        public async Task <dto.GetOrganizationResponse> GetAgency(dto.GetOrganizationRequestData requestData)
        {
            var signature = !string.IsNullOrEmpty(await _sessionBag.Signature())
                    ? await _sessionBag.Signature()
                    : await _userSessionService.GetAnonymousSharedSignature();

            GetOrganizationResponse response = await _agentClient.GetOrganizationAsync(new GetOrganizationRequest
            {
                ContractVersion        = _navApiContractVer,
                MessageContractVersion = _navMsgContractVer,
                Signature = signature,
                EnableExceptionStackTrace = false,
                GetOrganizationReqData    = new GetOrganizationRequestData
                {
                    OrganizationCode = requestData.OrganizationCode.ToUpper()
                }
            });

            return(new dto.GetOrganizationResponse
            {
                Organization = Mapper.Map <dto.Organization>(response.Organization)
            });
        }
Exemplo n.º 3
0
        public async Task <dto.GetStationListResponse> GetStationList(string cultureCode = null)
        {
            var culture = !string.IsNullOrEmpty(cultureCode) ? cultureCode : await _sessionBag.CultureCode();

            var signature = !string.IsNullOrEmpty(await _sessionBag.Signature())
                    ? await _sessionBag.Signature()
                    : await _userSessionService.GetAnonymousSharedSignature();

            var stationListCacheKey = string.Format("stationList_{0}_{1}", culture, await _sessionBag.RoleCode());

            var cachedStationList = _cache.Get <dto.GetStationListResponse>(stationListCacheKey);

            if (cachedStationList != null)
            {
                return(cachedStationList);
            }
            await _semaphoreSlimStationList.WaitAsync();

            try
            {
                cachedStationList = _cache.Get <dto.GetStationListResponse>(stationListCacheKey);
                if (cachedStationList != null)
                {
                    return(cachedStationList);
                }
                var stationsResp = await _client.GetStationListAsync(new GetStationListRequest
                {
                    ContractVersion        = _navApiContractVer,
                    MessageContractVersion = _navMsgContractVer,
                    Signature = signature,
                    EnableExceptionStackTrace = false,
                    GetStationListRequestData = new GetStationListRequestData {
                        CultureCode = culture
                    }
                });

                //_navApiContractVer, false,
                //_navMsgContractVer, signature, new GetStationListRequestData { CultureCode = culture });
                return(_cache.Set(stationListCacheKey, _mapper.Map <dto.GetStationListResponse>(stationsResp),
                                  _newskiesSettings.ResourcesCachePeriod));
            }
            finally
            {
                _semaphoreSlimStationList.Release();
            }
        }
Exemplo n.º 4
0
        public async Task <dto.ApplyPromotionResponse> ApplyPromotion(dto.ApplyPromotionRequestData request)
        {
            var signature = !string.IsNullOrEmpty(await _sessionBag.Signature())
                    ? await _sessionBag.Signature()
                    : await _userSessionService.GetAnonymousSharedSignature();

            var reqData  = Mapper.Map <ApplyPromotionRequestData>(request);
            var response = await _client.ApplyPromotionAsync(new ApplyPromotionRequest
            {
                ContractVersion           = _navApiContractVer,
                EnableExceptionStackTrace = false,
                Signature             = signature,
                ApplyPromotionReqData = reqData
            });

            await GetSessionBooking(true);

            var convertedResponse =
                Mapper.Map <dto.ApplyPromotionResponse>(response);

            return(convertedResponse);
        }
Exemplo n.º 5
0
        public async Task <dto.TripAvailabilityResponse> FindFlights(dto.TripAvailabilityRequest request)
        {
            var signature = !string.IsNullOrEmpty(await _sessionBag.Signature())
                    ? await _sessionBag.Signature()
                    : await _userSessionService.GetAnonymousSharedSignature();

            var tripAvailabilityRequest = Mapper.Map <TripAvailabilityRequest>(request, m => m.AfterMap(SetFareTypes));
            var stopWatch = _perfLogSettings.EnableNavApiLogging ? Stopwatch.StartNew() : null;
            var response  = await _client.GetAvailabilityVer2Async(new GetAvailabilityRequest
            {
                ContractVersion        = _navApiContractVer,
                MessageContractVersion = _navMsgContractVer,
                Signature = signature,
                EnableExceptionStackTrace = false,
                TripAvailabilityRequest   = tripAvailabilityRequest
            });

            //_navApiContractVer, false,
            //_navMsgContractVer, signature, tripAvailabilityRequest);
            if (_perfLogSettings.EnableNavApiLogging && stopWatch != null)
            {
                stopWatch.Stop();
                var msecs = stopWatch.ElapsedMilliseconds;
                _logger.WriteTimedLog(msecs, "BookingManager.GetAvailabilityVer2Async" + "|" + signature);
            }
            var avRequestWithInfant = Array.Find(request.AvailabilityRequests, p => Array.Find(
                                                     p.PaxTypeCounts, q => q.PaxTypeCode == Global.INFANT_CODE && q.PaxCount > 0) != null);

            if (avRequestWithInfant != null)
            {
                var infantCount = Array.Find(avRequestWithInfant.PaxTypeCounts,
                                             q => q.PaxTypeCode == Global.INFANT_CODE).PaxCount;
                foreach (var schedule in response.GetTripAvailabilityVer2Response.Schedules)
                {
                    foreach (var market in schedule)
                    {
                        foreach (var journey in market.AvailableJourneys)
                        {
                            var clearFares = false;
                            foreach (var segment in journey.AvailableSegment)
                            {
                                foreach (var leg in segment.Legs)
                                {
                                    var legSSRInsufficient = Array.Find(leg.LegInfo.LegSSRs, p => p.SSRNestCode == Global.INFANT_CODE &&
                                                                        p.SSRLid - p.SSRSold < infantCount);
                                    if (legSSRInsufficient != null)
                                    {
                                        clearFares = true;
                                        continue;
                                    }
                                }
                                if (clearFares)
                                {
                                    continue;
                                }
                            }
                            if (clearFares)
                            {
                                foreach (var segment in journey.AvailableSegment)
                                {
                                    segment.AvailableFares = new AvailableFare2[0];
                                }
                            }
                        }
                    }
                }
            }
            var convertedResponse =
                Mapper.Map <dto.TripAvailabilityResponse>(response.GetTripAvailabilityVer2Response);

            return(convertedResponse);
        }