public AvailabilitySearchRsp Availability()
        {
            AvailabilitySearchReq request = new AvailabilitySearchReq();
            AvailabilitySearchRsp rsp     = new AvailabilitySearchRsp();

            request = SetupRequestForSearch(request);

            AirAvailabilitySearchPortTypeClient client = new AirAvailabilitySearchPortTypeClient("AirAvailabilitySearchPort", WsdlService.AIR_ENDPOINT);

            client.ClientCredentials.UserName.UserName = Helper.RetrunUsername();
            client.ClientCredentials.UserName.Password = Helper.ReturnPassword();
            try
            {
                var httpHeaders = Helper.ReturnHttpHeader();
                client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));

                rsp = client.service(null, request);
                // Console.WriteLine(rsp.AirItinerarySolution.Count());
                // Console.WriteLine(rsp.AirSegmentList.Count());
            }
            catch (Exception se)
            {
                Console.WriteLine("Error : " + se.Message);
                client.Abort();
            }

            return(rsp);
        }
        public ActionResult AirSearch()
        {
            var origin      = Request["origin"];
            var destination = Request["destination"];
            var departure   = string.Format("{0:yyyy-MM-dd}", DateTime.Parse(Request["departure"]));
            var returning   = string.Format("{0:yyyy-MM-dd}", DateTime.Parse(Request["returning"]));
            var gds         = Request["gds"];

            var adult    = Request["adults"];
            var children = Request["children"];
            var infants  = Request["infants"];

            AvailabilitySearchRsp avaibalityRsp = new AvailabilitySearchRsp();

            try
            {
                AirSvcTest airTest = new AirSvcTest(origin, destination, departure, returning, gds);
                avaibalityRsp = airTest.Availability();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error : " + e.Message);
            }

            ViewBag.flightDetails = avaibalityRsp.AirSegmentList;

            return(View());
        }
Пример #3
0
        public AirAvailabilityResponseMain ConverToModel(AvailabilitySearchRsp rsp)
        {
            var bLoop         = false;
            var iSegmentCount = 0;
            AirAvailabilityResponseMain respMain = new AirAvailabilityResponseMain();

            respMain.AirAvailabilityResponse = new System.Collections.Generic.List <AirAvailabilityResponse>();
            AirAvailabilityResponse response = new AirAvailabilityResponse();

            response.AirAvailabilityResult = new System.Collections.Generic.List <AirAvailabilityResult>();
            AirAvailabilityResult result = new AirAvailabilityResult();

            System.Collections.Generic.List <AirAvailabilityResponse> liAirAvailabilityResponse = new System.Collections.Generic.List <AirAvailabilityResponse>();
            System.Collections.Generic.List <AirAvailabilityResult>   liAirAvailabilityResult   = new System.Collections.Generic.List <AirAvailabilityResult>();
            if (rsp != null)
            {
                var j = 0;
                for (var i = 0; i < rsp.AirItinerarySolution[0].Connection.Length; i++)
                {
                    if (i == 0)
                    {
                        while (j < rsp.AirItinerarySolution[0].Connection[i].SegmentIndex)
                        {
                            liAirAvailabilityResult   = new System.Collections.Generic.List <AirAvailabilityResult>();
                            liAirAvailabilityResponse = new System.Collections.Generic.List <AirAvailabilityResponse>();
                            response = new AirAvailabilityResponse();
                            response.AirAvailabilityResult = new System.Collections.Generic.List <AirAvailabilityResult>();
                            liAirAvailabilityResult.Add(new AirAvailabilityResult()
                            {
                                From = rsp.FlightDetailsList[j].Origin,
                                To   = rsp.FlightDetailsList[j].Destination
                            });
                            response.AirAvailabilityResult.AddRange(liAirAvailabilityResult);
                            respMain.AirAvailabilityResponse.Add(response);
                            j++;
                        }
                        j = rsp.AirItinerarySolution[0].Connection[i].SegmentIndex;
                    }
                    else if (i < rsp.AirItinerarySolution[0].Connection.Length - 1)
                    {
                        response = new AirAvailabilityResponse();
                        response.AirAvailabilityResult = new System.Collections.Generic.List <AirAvailabilityResult>();
                        liAirAvailabilityResult        = new System.Collections.Generic.List <AirAvailabilityResult>();
                        liAirAvailabilityResponse      = new System.Collections.Generic.List <AirAvailabilityResponse>();
                        while (j < rsp.AirItinerarySolution[0].Connection[i].SegmentIndex)
                        {
                            liAirAvailabilityResult = new System.Collections.Generic.List <AirAvailabilityResult>();
                            liAirAvailabilityResult.Add(new AirAvailabilityResult()
                            {
                                From = rsp.FlightDetailsList[j].Origin,
                                To   = rsp.FlightDetailsList[j].Destination
                            });
                            response.AirAvailabilityResult.AddRange(liAirAvailabilityResult);
                            iSegmentCount = rsp.AirItinerarySolution[0].Connection[i].SegmentIndex;
                            j++;
                        }
                        respMain.AirAvailabilityResponse.Add(response);
                        j = rsp.AirItinerarySolution[0].Connection[i].SegmentIndex;
                    }
                    else if (rsp.AirItinerarySolution[0].Connection.Length - 1 == i)
                    {
                        response = new AirAvailabilityResponse();
                        response.AirAvailabilityResult = new System.Collections.Generic.List <AirAvailabilityResult>();
                        liAirAvailabilityResult        = new System.Collections.Generic.List <AirAvailabilityResult>();
                        liAirAvailabilityResponse      = new System.Collections.Generic.List <AirAvailabilityResponse>();
                        j = rsp.AirItinerarySolution[0].Connection[i].SegmentIndex;
                        while (j < rsp.AirSegmentList.Length)
                        {
                            liAirAvailabilityResult = new System.Collections.Generic.List <AirAvailabilityResult>();
                            liAirAvailabilityResult.Add(new AirAvailabilityResult()
                            {
                                From = rsp.FlightDetailsList[j].Origin,
                                To   = rsp.FlightDetailsList[j].Destination
                            });
                            response.AirAvailabilityResult.AddRange(liAirAvailabilityResult);
                            iSegmentCount = rsp.AirItinerarySolution[0].Connection[i].SegmentIndex;
                            j++;
                        }
                        respMain.AirAvailabilityResponse.Add(response);
                    }
                }
            }
            return(respMain);
        }
Пример #4
0
        /// <summary>
        /// Get Universal Record
        /// </summary>
        /// <returns></returns>
        ///
        private AvailabilitySearchRsp GetAirAvailability()
        {
            AvailabilitySearchRsp response = null;



            string someTraceId = "doesntmatter-8176";
            string originApp   = "UAPI";

            AvailabilitySearchReq req = new AvailabilitySearchReq();

            req.TraceId      = someTraceId;
            req.AuthorizedBy = "user";
            req.TargetBranch = "P7001182";
            req.RetrieveProviderReservationDetails = true;

            ATPI.TWME.SP.Lib.AirService.BillingPointOfSaleInfo billSetInfo = new ATPI.TWME.SP.Lib.AirService.BillingPointOfSaleInfo();
            billSetInfo.OriginApplication = originApp;

            Airport org = new Airport()
            {
                Code = "SYD"
            };
            Airport dest = new Airport()
            {
                Code = "MEL"
            };

            SearchAirLeg leg = new SearchAirLeg();


            AddDepartureDate(leg, daysInFuture(1));

            List <typeSearchLocation> locs = new List <typeSearchLocation>();

            locs.Add(new typeSearchLocation()
            {
                Item = org
            });

            leg.SearchOrigin = locs.ToArray();

            List <typeSearchLocation> locs1 = new List <typeSearchLocation>();

            locs1.Add(new typeSearchLocation()
            {
                Item = dest
            });

            leg.SearchDestination = locs1.ToArray();


            req.BillingPointOfSaleInfo = billSetInfo;

            req.Items = new object[1] {
                leg
            };

            var mod = new AirSearchModifiers();

            mod.PreferredProviders = new List <ATPI.TWME.SP.Lib.AirService.Provider>()
            {
                new ATPI.TWME.SP.Lib.AirService.Provider()
                {
                    Code = "1G"
                }
            }.ToArray();

            req.AirSearchModifiers = mod;


            try
            {
                BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

                binding.Security.Transport.ProxyCredentialType  = HttpProxyCredentialType.Basic;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
                string          uri             = "https://americas.universal-api.pp.travelport.com/B2BGateway/connect/uAPI/AirService";
                EndpointAddress endpointAddress = new EndpointAddress(uri);

                AirAvailabilitySearchPortTypeClient client = new AirAvailabilitySearchPortTypeClient(binding, endpointAddress);
                if (client.ClientCredentials != null)
                {
                    client.ClientCredentials.UserName.UserName = "******";
                    client.ClientCredentials.UserName.Password = "******";
                }

                response = client.service(null, req);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(response);
        }