Beispiel #1
0
        /// <summary>
        /// booking the selected hotel
        /// </summary>
        /// <param name="hotelDetailsResponse"></param>
        /// <param name="hostToken"></param>
        /// <returns></returns>
        ///

        internal HotelCreateReservationRsp HotelBook(HotelDetailsRsp hotelDetailsResponse, HotelService.HostToken hostToken)
        {
            HotelCreateReservationReq hotelCreateReservationReq = new HotelCreateReservationReq();

            //If you want to create HotelBooking in the same UniversalRecord generated in AirCreateReservationRsp
            hotelCreateReservationReq.UniversalRecordLocatorCode = "Use Universal Record Locator Code generated in the AirBooking";
            UniversalService.BillingPointOfSaleInfo billSaleInfo = new UniversalService.BillingPointOfSaleInfo();
            billSaleInfo.OriginApplication = CommonUtility.GetConfigValue(ProjectConstants.APP);

            hotelCreateReservationReq.BillingPointOfSaleInfo = billSaleInfo;
            hotelCreateReservationReq.TargetBranch           = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH);
            hotelCreateReservationReq.TraceId = "Trace";

            //create two booking traveler, phone number, email and address details
            UniversalService.BookingTraveler bookingTravelerOne = new UniversalService.BookingTraveler();
            bookingTravelerOne.Age                 = "47";
            bookingTravelerOne.DOB                 = Convert.ToDateTime("1967-11-23");
            bookingTravelerOne.Gender              = "F";
            bookingTravelerOne.Nationality         = "AU";
            bookingTravelerOne.TravelerType        = "ADT";
            bookingTravelerOne.BookingTravelerName = new UniversalService.BookingTravelerName()
            {
                First  = "Charlotte",
                Last   = "Greene",
                Prefix = "MRS"
            };
            UniversalService.PhoneNumber phoneNumberOne = new UniversalService.PhoneNumber()
            {
                AreaCode    = "08",
                CountryCode = "61",
                Location    = "PER",
                Number      = "40003000",
                Type        = UniversalService.PhoneNumberType.Home
            };

            bookingTravelerOne.PhoneNumber    = new UniversalService.PhoneNumber[1];
            bookingTravelerOne.PhoneNumber[0] = phoneNumberOne;



            UniversalService.Email emailOne = new UniversalService.Email()
            {
                EmailID = "*****@*****.**",
                Type    = "Home"
            };

            bookingTravelerOne.Email    = new UniversalService.Email[1];
            bookingTravelerOne.Email[0] = emailOne;

            UniversalService.typeStructuredAddress addressOne = new UniversalService.typeStructuredAddress()
            {
                AddressName = "Home",
                Street      = new[] { "10 Charlie Street" },
                City        = "Perth",
                State       = new UniversalService.State()
                {
                    Value = "WA"
                },
                PostalCode = "6000",
                Country    = "AU"
            };

            bookingTravelerOne.Address    = new UniversalService.typeStructuredAddress[1];
            bookingTravelerOne.Address[0] = addressOne;



            UniversalService.BookingTraveler bookineTravelerTwo = new UniversalService.BookingTraveler();
            bookineTravelerTwo.Age                 = "50";
            bookineTravelerTwo.DOB                 = Convert.ToDateTime("1970-05-09");
            bookineTravelerTwo.Gender              = "M";
            bookineTravelerTwo.Nationality         = "AU";
            bookineTravelerTwo.TravelerType        = "ADT";
            bookineTravelerTwo.BookingTravelerName = new UniversalService.BookingTravelerName()
            {
                First  = "Eliott",
                Last   = "Greene",
                Prefix = "MR"
            };
            UniversalService.PhoneNumber phoneNumberTwo = new UniversalService.PhoneNumber()
            {
                AreaCode    = "08",
                CountryCode = "61",
                Location    = "PER",
                Number      = "40003000",
                Type        = UniversalService.PhoneNumberType.Home
            };

            bookineTravelerTwo.PhoneNumber    = new UniversalService.PhoneNumber[1];
            bookineTravelerTwo.PhoneNumber[0] = phoneNumberTwo;


            UniversalService.Email emailTwo = new UniversalService.Email()
            {
                EmailID = "*****@*****.**",
                Type    = "Home"
            };

            bookineTravelerTwo.Email    = new UniversalService.Email[1];
            bookineTravelerTwo.Email[0] = emailTwo;

            UniversalService.typeStructuredAddress addressTwo = new UniversalService.typeStructuredAddress()
            {
                AddressName = "Home",
                Street      = new[] { "10 Charlie Street" },
                City        = "Perth",
                State       = new UniversalService.State()
                {
                    Value = "WA"
                },
                PostalCode = "6000",
                Country    = "AU"
            };

            bookineTravelerTwo.Address    = new UniversalService.typeStructuredAddress[1];
            bookineTravelerTwo.Address[0] = addressTwo;

            hotelCreateReservationReq.BookingTraveler    = new UniversalService.BookingTraveler[2];
            hotelCreateReservationReq.BookingTraveler[0] = bookingTravelerOne;
            hotelCreateReservationReq.BookingTraveler[1] = bookineTravelerTwo;

            HotelService.GuaranteeInfo hotelGurrenteeInfo = null;
            RequestedHotelDetails      reqHotelDetails    = new RequestedHotelDetails();
            //select a hotel rate details and book the hotel using that one
            IEnumerator items = hotelDetailsResponse.Items.GetEnumerator();

            while (items.MoveNext())
            {
                var item = items.Current;
                reqHotelDetails = (RequestedHotelDetails)item;
            }

            if (reqHotelDetails.HotelRateDetail.Count() > 0)
            {
                IEnumerator <HotelService.HotelRateDetail> rateDetails = reqHotelDetails.HotelRateDetail.ToList().GetEnumerator();
                if (rateDetails.MoveNext())
                {
                    HotelService.HotelRateDetail rateDetail = rateDetails.Current;
                    List <UniversalApiClient.UniversalService.HotelRateDetail> hotelRateDetails = new List <UniversalService.HotelRateDetail>();
                    hotelRateDetails.Add(new UniversalService.HotelRateDetail()
                    {
                        ApproximateBase                    = rateDetail.ApproximateBase ?? null,
                        ApproximateRateGuaranteed          = rateDetail.ApproximateRateGuaranteed,
                        ApproximateRateGuaranteedSpecified = rateDetail.ApproximateRateGuaranteedSpecified,
                        ApproximateSurcharge               = rateDetail.ApproximateSurcharge ?? null,
                        ApproximateTax   = rateDetail.ApproximateTax ?? null,
                        ApproximateTotal = rateDetail.ApproximateTotal ?? null,
                        Base             = rateDetail.Base ?? null,
                        RateCategory     = rateDetail.RateCategory ?? null,
                        RatePlanType     = rateDetail.RatePlanType ?? null,
                        RateOfferId      = rateDetail.RateOfferId ?? null,
                        Tax          = rateDetail.Tax ?? null,
                        RateSupplier = rateDetail.RateSupplier ?? null,
                        Total        = rateDetail.Total ?? null
                    });
                    hotelCreateReservationReq.HotelRateDetail = hotelRateDetails.ToArray();

                    hotelGurrenteeInfo = rateDetail.GuaranteeInfo;
                }
            }


            hotelCreateReservationReq.HotelProperty = new UniversalService.HotelProperty()
            {
                HotelChain      = reqHotelDetails.HotelProperty.HotelChain ?? null,
                HotelCode       = reqHotelDetails.HotelProperty.HotelCode ?? null,
                HotelLocation   = reqHotelDetails.HotelProperty.HotelLocation ?? null,
                Name            = reqHotelDetails.HotelProperty.Name ?? null,
                PropertyAddress = reqHotelDetails.HotelProperty.PropertyAddress ?? null,
            };

            hotelCreateReservationReq.HotelStay = new UniversalService.HotelStay()
            {
                CheckinDate  = GetHotelStay().CheckinDate,
                CheckoutDate = GetHotelStay().CheckoutDate
            };

            //create payment info
            UniversalService.CreditCard ccInfo = new UniversalService.CreditCard()
            {
                BankCountryCode = GetCreditCardDetails().BankCountryCode,
                BankName        = GetCreditCardDetails().BankName,
                Number          = GetCreditCardDetails().Number,
                Type            = GetCreditCardDetails().Type,
                ExpDate         = GetCreditCardDetails().ExpDate,
                Name            = bookingTravelerOne.BookingTravelerName.First + bookingTravelerOne.BookingTravelerName.Last,
                CVV             = GetCreditCardDetails().CVV
            };


            //check if guarantee tyoe is Deopsit or not
            // MILAN:: Commented below if/else block which was giving error.
            if (hotelGurrenteeInfo.GuaranteeType.ToString().CompareTo((HotelService.GuaranteeType.Deposit.ToString())) == 0)
            {
                hotelCreateReservationReq.Guarantee = new UniversalService.Guarantee()
                {
                    Type = UniversalService.GuaranteeType.Deposit,
                    Item = ccInfo
                };
            }
            else if (hotelGurrenteeInfo.GuaranteeType.ToString().CompareTo((HotelService.GuaranteeType.Guarantee.ToString())) == 0)
            {
                hotelCreateReservationReq.Guarantee = new UniversalService.Guarantee()
                {
                    Type = UniversalService.GuaranteeType.Guarantee,
                    Item = ccInfo
                };
            }

            hotelCreateReservationReq.GuestInformation = new UniversalService.GuestInformation()
            {
                NumberOfRooms  = numberOfRooms,
                NumberOfAdults = new UniversalService.NumberOfAdults()
                {
                    Value = numberOfAdults.ToString()
                }
            };

            if (hostToken != null && hostToken.Value != null)
            {
                hotelCreateReservationReq.HostToken = new UniversalService.HostToken()
                {
                    Host  = hostToken.Host,
                    Key   = hostToken.Key ?? null,
                    Value = hostToken.Value
                };
            }

            HotelReservationServicePortTypeClient hotelBookclient = new HotelReservationServicePortTypeClient("HotelReservationServicePort", WsdlService.HOTEL_ENDPOINT);

            hotelBookclient.ClientCredentials.UserName.UserName = Helper.RetrunUsername();
            hotelBookclient.ClientCredentials.UserName.Password = Helper.ReturnPassword();

            try
            {
                var httpHeaders = Helper.ReturnHttpHeader();
                hotelBookclient.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));

                hotelCreateReservationRsp = hotelBookclient.service(null, hotelCreateReservationReq);
            }
            catch (Exception se)
            {
                Console.WriteLine("Error : " + se.Message);
                hotelBookclient.Abort();
            }

            return(hotelCreateReservationRsp);
        }
        private UniversalService.BookingTraveler[] AddBookingTravler()
        {
            List <UniversalService.BookingTraveler> travelers = new List <UniversalService.BookingTraveler>();

            //Adding First Booking Traveler
            UniversalService.BookingTraveler traveler = new UniversalService.BookingTraveler();
            traveler.DOB          = DateTime.Now.AddYears(-28);
            traveler.Gender       = "M";
            traveler.TravelerType = "ADT";
            traveler.Key          = "gr8AVWGCR064r57Jt0+8bA==";
            traveler.Nationality  = "US";

            traveler.BookingTravelerName = new UniversalService.BookingTravelerName()
            {
                First  = "Jack",
                Last   = "Smith",
                Prefix = "Mr"
            };

            UniversalService.DeliveryInfoShippingAddress shipping = new UniversalService.DeliveryInfoShippingAddress()
            {
                AddressName = "Home",
                Street      = new string[] { "2914 N. Dakota Avenue" },
                City        = "Denver",
                State       = new UniversalService.State()
                {
                    Value = "CO"
                },
                PostalCode = "80206",
                Country    = "US"
            };

            List <UniversalService.DeliveryInfo> deliveryInfoList = new List <UniversalService.DeliveryInfo>();

            UniversalService.DeliveryInfo deliveryInfo = new UniversalService.DeliveryInfo()
            {
                ShippingAddress = shipping
            };

            deliveryInfoList.Add(deliveryInfo);

            traveler.DeliveryInfo = deliveryInfoList.ToArray();

            List <UniversalService.PhoneNumber> phoneList = new List <UniversalService.PhoneNumber>();

            UniversalService.PhoneNumber phoneNum = new UniversalService.PhoneNumber()
            {
                AreaCode    = "303",
                CountryCode = "1",
                Number      = "3333333",
                Location    = "DEN"
            };

            phoneList.Add(phoneNum);

            traveler.PhoneNumber = phoneList.ToArray();

            List <UniversalService.Email> emailList = new List <UniversalService.Email>();

            UniversalService.Email email = new UniversalService.Email()
            {
                EmailID = "*****@*****.**",
                Type    = "Home"
            };

            emailList.Add(email);

            traveler.Email = emailList.ToArray();

            List <UniversalService.typeStructuredAddress> addressList = new List <UniversalService.typeStructuredAddress>();

            UniversalService.typeStructuredAddress address = new UniversalService.typeStructuredAddress()
            {
                AddressName = "Home",
                Street      = new string[] { "2914 N. Dakota Avenue" },
                City        = "Denver",
                State       = new UniversalService.State()
                {
                    Value = "CO"
                },
                PostalCode = "80206",
                Country    = "US"
            };

            addressList.Add(address);

            traveler.Address = addressList.ToArray();

            travelers.Add(traveler);

            return(travelers.ToArray());
        }
        /// <summary>
        /// booking the selected hotel
        /// </summary>
        /// <param name="hotelDetailsResponse"></param>
        /// <param name="hostToken"></param>
        /// <returns></returns>
        internal HotelCreateReservationRsp HotelBook(HotelDetailsRsp hotelDetailsResponse, HotelService.HostToken hostToken)
        {
            HotelCreateReservationReq hotelCreateReservationReq = new HotelCreateReservationReq();
            UniversalService.BillingPointOfSaleInfo billSaleInfo = new UniversalService.BillingPointOfSaleInfo();
            billSaleInfo.OriginApplication = CommonUtility.GetConfigValue(ProjectConstants.APP);

            hotelCreateReservationReq.BillingPointOfSaleInfo = billSaleInfo;
            hotelCreateReservationReq.TargetBranch = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH);
            hotelCreateReservationReq.TraceId = "Trace";

            //create two booking traveler, phone number, email and address details
            UniversalService.BookingTraveler bookingTravelerOne = new UniversalService.BookingTraveler();
            bookingTravelerOne.Age = "47";
            bookingTravelerOne.DOB = Convert.ToDateTime("1967-11-23");
            bookingTravelerOne.Gender = "F";
            bookingTravelerOne.Nationality = "AU";
            bookingTravelerOne.TravelerType = "ADT";
            bookingTravelerOne.BookingTravelerName = new UniversalService.BookingTravelerName(){
                First = "Charlotte",
                Last = "Greene",
                Prefix = "MRS"
            };
            UniversalService.PhoneNumber phoneNumberOne= new UniversalService.PhoneNumber()
            {
                AreaCode = "08",
                CountryCode = "61",
                Location = "PER",
                Number = "40003000",
                Type = UniversalService.PhoneNumberType.Home
            };

            bookingTravelerOne.PhoneNumber = new UniversalService.PhoneNumber[1];
            bookingTravelerOne.PhoneNumber[0] = phoneNumberOne;



            UniversalService.Email emailOne = new UniversalService.Email()
            {
                EmailID = "*****@*****.**",
                Type = "Home"
            };

            bookingTravelerOne.Email = new UniversalService.Email[1];
            bookingTravelerOne.Email[0] = emailOne;

            UniversalService.typeStructuredAddress addressOne = new UniversalService.typeStructuredAddress()
            {
                AddressName = "Home",
                Street = new[] { "10 Charlie Street" },
                City = "Perth",
                State = new UniversalService.State()
                {
                    Value = "WA"
                },
                PostalCode = "6000",
                Country = "AU"
            };

            bookingTravelerOne.Address = new UniversalService.typeStructuredAddress[1];
            bookingTravelerOne.Address[0] = addressOne;



            UniversalService.BookingTraveler bookineTravelerTwo = new UniversalService.BookingTraveler();
            bookineTravelerTwo.Age = "50";
            bookineTravelerTwo.DOB = Convert.ToDateTime("1970-05-09");
            bookineTravelerTwo.Gender = "M";
            bookineTravelerTwo.Nationality = "AU";
            bookineTravelerTwo.TravelerType = "ADT";
            bookineTravelerTwo.BookingTravelerName = new UniversalService.BookingTravelerName()
            {
                First = "Eliott",
                Last = "Greene",
                Prefix = "MR"
            };
            UniversalService.PhoneNumber phoneNumberTwo = new UniversalService.PhoneNumber()
            {
                AreaCode = "08",
                CountryCode = "61",
                Location = "PER",
                Number = "40003000",
                Type = UniversalService.PhoneNumberType.Home
            };

            bookineTravelerTwo.PhoneNumber = new UniversalService.PhoneNumber[1];
            bookineTravelerTwo.PhoneNumber[0] = phoneNumberTwo;


            UniversalService.Email emailTwo = new UniversalService.Email()
            {
                EmailID = "*****@*****.**",
                Type = "Home"
            };

            bookineTravelerTwo.Email = new UniversalService.Email[1];
            bookineTravelerTwo.Email[0] = emailTwo;

            UniversalService.typeStructuredAddress addressTwo = new UniversalService.typeStructuredAddress()
            {
                AddressName = "Home",
                Street = new[] { "10 Charlie Street" },
                City = "Perth",
                State = new UniversalService.State()
                {
                    Value = "WA"
                },
                PostalCode = "6000",
                Country = "AU"
            };

            bookineTravelerTwo.Address = new UniversalService.typeStructuredAddress[1];
            bookineTravelerTwo.Address[0] = addressTwo;

            hotelCreateReservationReq.BookingTraveler = new UniversalService.BookingTraveler[2];
            hotelCreateReservationReq.BookingTraveler[0] = bookingTravelerOne;
            hotelCreateReservationReq.BookingTraveler[1] = bookineTravelerTwo;

            HotelService.GuaranteeInfo hotelGurrenteeInfo = null;
            //select a hotel rate details and book the hotel using that one
            RequestedHotelDetails reqHotelDetails = (RequestedHotelDetails)hotelDetailsResponse.Item;
            if (reqHotelDetails.HotelRateDetail.Count() > 0)
            {
                IEnumerator<HotelService.HotelRateDetail> rateDetails = reqHotelDetails.HotelRateDetail.ToList().GetEnumerator();
                if (rateDetails.MoveNext())
                {
                    HotelService.HotelRateDetail rateDetail = rateDetails.Current;
                    hotelCreateReservationReq.HotelRateDetail = new UniversalService.HotelRateDetail()
                    {
                        ApproximateBase = rateDetail.ApproximateBase ?? null,
                        ApproximateRateGuaranteed = rateDetail.ApproximateRateGuaranteed,
                        ApproximateRateGuaranteedSpecified = rateDetail.ApproximateRateGuaranteedSpecified,
                        ApproximateSurcharge = rateDetail.ApproximateSurcharge ?? null,
                        ApproximateTax = rateDetail.ApproximateTax ?? null,
                        ApproximateTotal = rateDetail.ApproximateTotal ?? null,
                        Base = rateDetail.Base ?? null,
                        RateCategory = rateDetail.RateCategory ?? null,
                        RatePlanType = rateDetail.RatePlanType ?? null,              
                        RateOfferId = rateDetail.RateOfferId ?? null,
                        Tax = rateDetail.Tax ?? null,
                        RateSupplier = rateDetail.RateSupplier ?? null,
                        Total = rateDetail.Total ?? null
                    };

                    hotelGurrenteeInfo = rateDetail.GuaranteeInfo;
                }
            }


            hotelCreateReservationReq.HotelProperty = new UniversalService.HotelProperty()
            {
                HotelChain = reqHotelDetails.HotelProperty.HotelChain ?? null,
                HotelCode = reqHotelDetails.HotelProperty.HotelCode ?? null,
                HotelLocation = reqHotelDetails.HotelProperty.HotelLocation ?? null,
                Name = reqHotelDetails.HotelProperty.Name ?? null,
                PropertyAddress = reqHotelDetails.HotelProperty.PropertyAddress ?? null,
            };

            hotelCreateReservationReq.HotelStay = new UniversalService.HotelStay()
            {
                CheckinDate = GetHotelStay().CheckinDate,
                CheckoutDate = GetHotelStay().CheckoutDate
            };

            //create payment info
            UniversalService.CreditCard ccInfo= new UniversalService.CreditCard()
            {
                BankCountryCode = GetCreditCardDetails().BankCountryCode,
                BankName = GetCreditCardDetails().BankName,
                Number = GetCreditCardDetails().Number,
                Type = GetCreditCardDetails().Type,
                ExpDate = GetCreditCardDetails().ExpDate,
                Name = bookingTravelerOne.BookingTravelerName.First + bookingTravelerOne.BookingTravelerName.Last,
                CVV = GetCreditCardDetails().CVV
            };


            //check if guarantee tyoe is Deopsit or not
            if (hotelGurrenteeInfo.GuaranteeType.ToString().CompareTo((HotelService.GuaranteeType.Deposit.ToString())) == 0)
            {
                hotelCreateReservationReq.Guarantee = new UniversalService.Guarantee()
                {
                    Type = UniversalService.GuaranteeType.Deposit,
                    Item = ccInfo
                };
            }
            else if (hotelGurrenteeInfo.GuaranteeType.ToString().CompareTo((HotelService.GuaranteeType.Guarantee.ToString())) == 0)
            {
                hotelCreateReservationReq.Guarantee = new UniversalService.Guarantee()
                {
                    Type = UniversalService.GuaranteeType.Guarantee,
                    Item = ccInfo
                };
            }

            hotelCreateReservationReq.GuestInformation = new UniversalService.GuestInformation()
            {
                NumberOfRooms = numberOfRooms,
                NumberOfAdults = new UniversalService.NumberOfAdults()
                {
                    Value = numberOfAdults.ToString()
                }
            };

            if (hostToken != null && hostToken.Value != null)
            {
                hotelCreateReservationReq.HostToken = new UniversalService.HostToken()
                {
                    Host = hostToken.Host,
                    Key = hostToken.Key ?? null,
                    Value = hostToken.Value
                };
            }



            HotelReservationServicePortTypeClient hotelBookclient = new HotelReservationServicePortTypeClient("HotelReservationServicePort", WsdlService.HOTEL_ENDPOINT);
            hotelBookclient.ClientCredentials.UserName.UserName = Helper.RetrunUsername();
            hotelBookclient.ClientCredentials.UserName.Password = Helper.ReturnPassword();

            try
            {
                var httpHeaders = Helper.ReturnHttpHeader();
                hotelBookclient.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));

                hotelCreateReservationRsp = hotelBookclient.service(null, hotelCreateReservationReq);                
            }
            catch (Exception se)
            {
                Console.WriteLine("Error : " + se.Message);
                hotelBookclient.Abort();
            }

            return hotelCreateReservationRsp;
        }