Exemple #1
0
        private AirPriceReq ConvertToAirPriceReq(AirPriceRQ request)
        {
            int         counter = 0;
            AirPriceReq req     = new AirPriceReq()
            {
                BillingPointOfSaleInfo = new kestrel.AirService.BillingPointOfSaleInfo
                {
                    OriginApplication = "uAPI"
                },
                TargetBranch = "P7073862",
                AirItinerary = new AirItinerary
                {
                    AirSegment = request.Segments.Select(s => new typeBaseAirSegment
                    {
                        Key            = s.Key,
                        Group          = s.Group,
                        FlightNumber   = s.FlightNumber.Number,
                        Carrier        = s.FlightNumber.Airline,
                        Origin         = s.Origin,
                        Destination    = s.Destination,
                        ProviderCode   = "1G",
                        DepartureTime  = $"{s.DepartureTime.Time.ToString("yyyy-MM-ddTHH:mm:ss.000")}+{s.DepartureTime.GmtOffset.ToString("00")}:00",
                        ArrivalTime    = $"{s.ArrivalTime.Time.ToString("yyyy-MM-ddTHH:mm:ss.000")}+{s.ArrivalTime.GmtOffset.ToString("00")}:00",
                        ClassOfService = s.ClassOfService,
                        Connection     = s.IsConnection ? new Connection {
                        } : null
                    }).ToArray()
                },
                SearchPassenger = request.Ptcs.Select(ptc =>
                {
                    SearchPassenger pax = new SearchPassenger
                    {
                        Code = ptc.Code,
                        BookingTravelerRef = $"PT{counter++}",
                    };
                    if (ptc.Age != null)
                    {
                        pax.Age = ptc.Age.ToString();
                    }
                    return(pax);
                }).ToArray(),
                AirPricingCommand = new AirPricingCommand[]
                {
                    new AirPricingCommand
                    {
                        CabinClass = request.CabinClass,
                    }
                },

                //AirPricingModifiers = new AirPricingModifiers
                //{
                //    BrandModifiers = new BrandModifiers
                //    {
                //        ModifierType = BrandModifiersModifierType.FareFamilyDisplay
                //    }
                //}
            };

            return(req);
        }
Exemple #2
0
        internal static AirPriceRsp AirPrice(List <typeBaseAirSegment> pricingSegments)
        {
            AirPriceReq priceReq = new AirPriceReq();
            AirPriceRsp priceRsp;

            AddPointOfSale(priceReq, "UAPI");

            AirItinerary itinerary = new AirItinerary();

            List <typeBaseAirSegment> itinerarySegments = new List <typeBaseAirSegment>();

            IEnumerator airSegments = pricingSegments.GetEnumerator();

            while (airSegments.MoveNext())
            {
                typeBaseAirSegment seg = (typeBaseAirSegment)airSegments.Current;
                seg.ProviderCode     = "1G";
                seg.FlightDetailsRef = null;
                seg.ClassOfService   = "Y";

                itinerarySegments.Add(seg);
            }

            itinerary.AirSegment = itinerarySegments.ToArray();

            priceReq.AirItinerary = itinerary;

            priceReq.SearchPassenger = AddSearchPassenger();

            priceReq.AirPricingModifiers = new AirPricingModifiers()
            {
                PlatingCarrier = priceReq.AirItinerary.AirSegment[0].Carrier
            };

            List <AirPricingCommand> pricingCommands = new List <AirPricingCommand>();

            AirPricingCommand command = new AirPricingCommand()
            {
                CabinClass = "Economy"//You can use Economy,PremiumEconomy,Business etc.
            };

            pricingCommands.Add(command);

            priceReq.AirPricingCommand = pricingCommands.ToArray();


            priceReq.TargetBranch = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH);

            AirPricePortTypeClient client = new AirPricePortTypeClient("AirPricePort", 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));

                priceRsp = client.service(null, priceReq);

                return(priceRsp);
            }
            catch (Exception se)
            {
                Console.WriteLine("Error : " + se.Message);
                client.Abort();
                return(null);
            }
        }
        internal static AirPriceRsp AirPrice(List<typeBaseAirSegment> pricingSegments)
        {
            AirPriceReq priceReq = new AirPriceReq();
            AirPriceRsp priceRsp;

            AddPointOfSale(priceReq, "UAPI");

            AirItinerary itinerary = new AirItinerary();

            List<typeBaseAirSegment> itinerarySegments = new List<typeBaseAirSegment>();

            IEnumerator airSegments = pricingSegments.GetEnumerator();
            while (airSegments.MoveNext())
            {
                typeBaseAirSegment seg = (typeBaseAirSegment)airSegments.Current;
                seg.ProviderCode = "1G";
                seg.FlightDetailsRef = null;

                itinerarySegments.Add(seg);
            }

            itinerary.AirSegment = itinerarySegments.ToArray();

            priceReq.AirItinerary = itinerary;

            priceReq.SearchPassenger = AddSearchPassenger();

            priceReq.AirPricingModifiers = new AirPricingModifiers()
            {
                PlatingCarrier = priceReq.AirItinerary.AirSegment[0].Carrier
            };

            List<AirPricingCommand> pricingCommands = new List<AirPricingCommand>();

            AirPricingCommand command = new AirPricingCommand()
            {
                CabinClass = "Economy"//You can use Economy,PremiumEconomy,Business etc.
            };

            pricingCommands.Add(command);

            priceReq.AirPricingCommand = pricingCommands.ToArray();
            

            priceReq.TargetBranch = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH);

            AirPricePortTypeClient client = new AirPricePortTypeClient("AirPricePort", 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));

                priceRsp = client.service(priceReq);                

                return priceRsp;
            }
            catch (Exception se)
            {
                Console.WriteLine("Error : " + se.Message);
                client.Abort();
                return null;
            }
        }