コード例 #1
0
ファイル: clsBooking.cs プロジェクト: DivakerSIngh/ofr
        public static eProvisionalBookingResponseModel CancelBooking(eProvisionalBookingRequestModel bookingModel)
        {
            try
            {
                #region New Modified Code

                Envelope objEnvelope = new Envelope();
                objEnvelope.S = "http://schemas.xmlsoap.org/soap/envelope/";

                Body objBody = new Body();
                objBody.Xsd = "http://www.w3.org/2001/XMLSchema";
                objBody.Xsi = "http://www.w3.org/2001/XMLSchema-instance";

                OTA_HotelResRQ objOTA_HotelResRQ = new OTA_HotelResRQ();

                POS objPOS = new POS();

                Source objSource = new Source();
                objSource.ISOCurrency = bookingModel.Currency;
                RequestorID objRequestorID = new RequestorID();
                objRequestorID.ID = bookingModel.API_Credential_PropertyId;
                objRequestorID.MessagePassword = bookingModel.API_Credential_Password;
                CompanyName objCompanyName = new CompanyName();
                objCompanyName.Code        = bookingModel.API_Credential_UserName;
                objRequestorID.CompanyName = objCompanyName;
                objSource.RequestorID      = objRequestorID;
                objPOS.Source = objSource;


                UniqueID objUniqueID = new UniqueID();
                objUniqueID.ID   = bookingModel.UniqueId;
                objUniqueID.Type = bookingModel.UniqueIdType;


                //==> Hotel Reservaltions
                HotelReservations objHotelReservations = new HotelReservations();
                HotelReservation  objHotelReservation  = new HotelReservation();

                ResGlobalInfo objResGlobalInfo = new ResGlobalInfo();
                Guarantee     objGuarantee     = new Guarantee();
                objGuarantee.GuaranteeType = bookingModel.GuaranteeType;
                objResGlobalInfo.Guarantee = objGuarantee;

                objHotelReservation.ResGlobalInfo = objResGlobalInfo;

                objHotelReservations.HotelReservation = objHotelReservation;

                objOTA_HotelResRQ.POS               = objPOS;
                objOTA_HotelResRQ.UniqueID          = objUniqueID;
                objOTA_HotelResRQ.HotelReservations = objHotelReservations;
                objOTA_HotelResRQ.Xmlns             = "http://www.w3.org/2001/XMLSchema";
                objOTA_HotelResRQ.Version           = "0";
                objOTA_HotelResRQ.CorrelationID     = bookingModel.CorrelationID;

                objBody.OTA_HotelResRQ = objOTA_HotelResRQ;
                objEnvelope.Body       = objBody;

                #endregion New Modified Code


                string xmlRequestBody = clsTravelGuruApi.ConvertToXmlString(objEnvelope);

                string status = clsTravelGuruApi.FetchBookingTravelGuruApi(xmlRequestBody);

                EnvelopePBRes objEnvelopeSHRes = clsTravelGuruApi.FromXml <EnvelopePBRes>(status);

                eProvisionalBookingResponseModel response = new eProvisionalBookingResponseModel();

                var apiResponse = objEnvelopeSHRes.Body.OTA_HotelResRS;

                if (apiResponse.Errors.Error != null)
                {
                    var error = objEnvelopeSHRes.Body.OTA_HotelResRS.Errors.Error;
                    response.IsSuccedded  = false;
                    response.ErrorCode    = error.Code;
                    response.ErrorMessage = error.Text;
                }
                else
                {
                    response.IsSuccedded   = true;
                    response.CorrelationID = apiResponse.CorrelationID;
                    response.UniqueId      = apiResponse.HotelReservations.HotelReservation.UniqueID.ID;
                    response.UniqueIdType  = apiResponse.HotelReservations.HotelReservation.UniqueID.Type;
                }

                return(response);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
ファイル: clsBooking.cs プロジェクト: DivakerSIngh/ofr
        public static eProvisionalBookingResponseModel ProvisionalBooking(TG_ProvisionalBookingRequestModel bookingModel)
        {
            try
            {
                #region New Modified Code

                Envelope objEnvelope = new Envelope();
                objEnvelope.S = "http://schemas.xmlsoap.org/soap/envelope/";

                Body objBody = new Body();
                objBody.Xsd = "http://www.w3.org/2001/XMLSchema";
                objBody.Xsi = "http://www.w3.org/2001/XMLSchema-instance";

                OTA_HotelResRQ objOTA_HotelResRQ = new OTA_HotelResRQ();

                POS objPOS = new POS();

                Source objSource = new Source();
                objSource.ISOCurrency = bookingModel.Currency;
                RequestorID objRequestorID = new RequestorID();
                objRequestorID.ID = bookingModel.API_Credential_PropertyId;
                objRequestorID.MessagePassword = bookingModel.API_Credential_Password;
                CompanyName objCompanyName = new CompanyName();
                objCompanyName.Code        = bookingModel.API_Credential_UserName;
                objRequestorID.CompanyName = objCompanyName;
                objSource.RequestorID      = objRequestorID;
                objPOS.Source = objSource;


                UniqueID objUniqueID = new UniqueID();
                objUniqueID.ID   = bookingModel.UniqueId;
                objUniqueID.Type = bookingModel.UniqueIdType;


                //==> Hotel Reservaltions
                HotelReservations objHotelReservations = new HotelReservations();
                HotelReservation  objHotelReservation  = new HotelReservation();
                RoomStays         objRoomStays         = new RoomStays();
                RoomStay          objRoomStay          = new RoomStay();

                RoomTypes objRoomTypes = new RoomTypes();
                RoomType  objRoomType  = new RoomType();
                objRoomType.RoomTypeCode  = bookingModel.RoomTypeCode;
                objRoomType.NumberOfUnits = bookingModel.NumberOfRooms;
                objRoomTypes.RoomType     = objRoomType;

                RatePlans objRatePlans = new RatePlans();
                RatePlan  objRatePlan  = new RatePlan();
                objRatePlan.RatePlanCode = bookingModel.RatePlanCode;
                objRatePlans.RatePlan    = objRatePlan;


                GuestCounts       objGuestCounts   = new GuestCounts();
                List <GuestCount> objGuestCountArr = new System.Collections.Generic.List <GuestCount>();

                foreach (var room in bookingModel.RoomData)
                {
                    GuestCount objAdultCount = new GuestCount();
                    objAdultCount.Count             = room.adult.ToString();
                    objAdultCount.AgeQualifyingCode = "10";
                    objGuestCountArr.Add(objAdultCount);

                    foreach (var item in room.ChildAge)
                    {
                        GuestCount objChildCount = new GuestCount();
                        objChildCount.Count             = "1";
                        objChildCount.AgeQualifyingCode = "8";
                        objChildCount.Age = item.Age;
                        objGuestCountArr.Add(objChildCount);
                    }
                }

                objGuestCounts.GuestCount = objGuestCountArr;

                TimeSpan objTimeSpan = new TimeSpan();
                objTimeSpan.End   = bookingModel.CheckOut;
                objTimeSpan.Start = bookingModel.CheckIn;

                Total objTotal = new Total();
                objTotal.CurrencyCode    = bookingModel.Currency;
                objTotal.AmountBeforeTax = bookingModel.AmountBeforeTax;
                Taxes objTaxes = new Taxes();
                objTaxes.CurrencyCode = bookingModel.Currency;
                objTaxes.Amount       = bookingModel.TaxAmount;
                objTotal.Taxes        = objTaxes;

                BasicPropertyInfo objBasicPropertyInfo = new BasicPropertyInfo();
                objBasicPropertyInfo.HotelCode = bookingModel.HotelCode;

                Comments objComments = new Comments();
                Comment  objComment  = new Comment();
                objComment.Text     = bookingModel.CustomerComment;
                objComments.Comment = objComment;

                objRoomStay.RoomTypes         = objRoomTypes;
                objRoomStay.RatePlans         = objRatePlans;
                objRoomStay.GuestCounts       = objGuestCounts;
                objRoomStay.TimeSpan          = objTimeSpan;
                objRoomStay.Total             = objTotal;
                objRoomStay.BasicPropertyInfo = objBasicPropertyInfo;
                objRoomStay.Comments          = objComments;
                objRoomStays.RoomStay         = objRoomStay;

                ResGuests   objResGuests   = new ResGuests();
                ResGuest    objResGuest    = new ResGuest();
                Profiles    objProfiles    = new Profiles();
                ProfileInfo objProfileInfo = new ProfileInfo();
                Profile     objProfile     = new Profile();
                objProfile.ProfileType = bookingModel.ProfileType;
                Customer objCustomer = new Customer();

                PersonName objPersonName = new PersonName();
                objPersonName.GivenName = bookingModel.CustomerGivenName;
                objPersonName.Surname   = bookingModel.CustomerSurname;

                Telephone objTelephone = new Telephone();
                objTelephone.PhoneTechType     = bookingModel.PhoneTechType;
                objTelephone.PhoneNumber       = bookingModel.PhoneNumber;
                objTelephone.CountryAccessCode = bookingModel.CountryAccessCode;

                Address objAddress = new Address();
                objAddress.AddressLine = bookingModel.AddressLine;
                objAddress.CityName    = bookingModel.CityName;
                objAddress.PostalCode  = bookingModel.PostalCode;


                StateProv objStateProv = new StateProv();
                objStateProv.StateCode = bookingModel.StateCode;
                objStateProv.Text      = bookingModel.StateName;

                CountryName objCountryName = new CountryName();
                objCountryName.Code = bookingModel.CountryCode;
                objCountryName.Text = bookingModel.CountryName;

                objAddress.StateProv   = objStateProv;
                objAddress.CountryName = objCountryName;

                objCustomer.PersonName = objPersonName;
                objCustomer.Telephone  = objTelephone;
                objCustomer.Email      = bookingModel.CustomerEmail;
                objCustomer.Address    = objAddress;

                objProfile.Customer = objCustomer;

                objProfileInfo.Profile = objProfile;

                objProfiles.ProfileInfo = objProfileInfo;

                objResGuest.Profiles = objProfiles;

                objResGuests.ResGuest = objResGuest;

                ResGlobalInfo objResGlobalInfo = new ResGlobalInfo();
                Guarantee     objGuarantee     = new Guarantee();
                objGuarantee.GuaranteeType = bookingModel.GuaranteeType;
                objResGlobalInfo.Guarantee = objGuarantee;

                objHotelReservation.RoomStays     = objRoomStays;
                objHotelReservation.ResGuests     = objResGuests;
                objHotelReservation.ResGlobalInfo = objResGlobalInfo;

                objHotelReservations.HotelReservation = objHotelReservation;

                objOTA_HotelResRQ.POS               = objPOS;
                objOTA_HotelResRQ.UniqueID          = objUniqueID;
                objOTA_HotelResRQ.HotelReservations = objHotelReservations;
                objOTA_HotelResRQ.Xmlns             = "http://www.w3.org/2001/XMLSchema";
                objOTA_HotelResRQ.Version           = "0";
                objOTA_HotelResRQ.CorrelationID     = bookingModel.CorrelationID;

                objBody.OTA_HotelResRQ = objOTA_HotelResRQ;
                objEnvelope.Body       = objBody;

                #endregion New Modified Code


                #region PreviousCode

                //Envelope objEnvelope = new Envelope();
                //objEnvelope.S = "http://schemas.xmlsoap.org/soap/envelope/";

                //Body objBody = new Body();
                //objBody.Xsd = "http://www.w3.org/2001/XMLSchema";
                //objBody.Xsi = "http://www.w3.org/2001/XMLSchema-instance";

                //OTA_HotelResRQ objOTA_HotelResRQ = new OTA_HotelResRQ();

                ////==> POS
                //POS objPOS = new POS();

                //Source objSource = new Source();
                //objSource.ISOCurrency = "INR";
                //RequestorID objRequestorID = new RequestorID();
                //objRequestorID.ID = "1300001224";
                //objRequestorID.MessagePassword = "******";
                //CompanyName objCompanyName = new CompanyName();
                //objCompanyName.Code = "samaara";
                //objRequestorID.CompanyName = objCompanyName;
                //objSource.RequestorID = objRequestorID;
                //objPOS.Source = objSource;
                ////==> End

                ////==> UniqueId
                //UniqueID objUniqueID = new UniqueID();
                //objUniqueID.ID = "";
                //objUniqueID.Type = "";

                ////==> End

                ////==> Hotel Reservaltions
                //HotelReservations objHotelReservations = new HotelReservations();
                //HotelReservation objHotelReservation = new HotelReservation();
                //RoomStays objRoomStays = new RoomStays();
                //RoomStay objRoomStay = new RoomStay();

                //RoomTypes objRoomTypes = new RoomTypes();
                //RoomType objRoomType = new RoomType();
                //objRoomType.RoomTypeCode = "0000116417";
                //objRoomType.NumberOfUnits = "1";
                //objRoomTypes.RoomType = objRoomType;

                //RatePlans objRatePlans = new RatePlans();
                //RatePlan objRatePlan = new RatePlan();
                //objRatePlan.RatePlanCode = "0000432031";
                //objRatePlans.RatePlan = objRatePlan;

                //GuestCounts objGuestCounts = new GuestCounts();
                //List<GuestCount> objGuestCountArr = new System.Collections.Generic.List<GuestCount>();
                //GuestCount objGuestCount = new GuestCount();
                //objGuestCount.Count = "1";
                //objGuestCount.AgeQualifyingCode = "10";
                //GuestCount objGuestCount2 = new GuestCount();
                //objGuestCount2.Count = "1";
                //objGuestCount2.AgeQualifyingCode = "8";
                //objGuestCount2.Age = "10";
                //objGuestCountArr.Add(objGuestCount);
                //objGuestCountArr.Add(objGuestCount2);
                //objGuestCounts.GuestCount = objGuestCountArr;

                //TimeSpan objTimeSpan = new TimeSpan();
                //objTimeSpan.Start = "2016-12-12";
                //objTimeSpan.End = "2016-12-15";

                //Total objTotal = new Total();
                //objTotal.CurrencyCode = "INR";
                //objTotal.AmountBeforeTax = "3400.0";
                //Taxes objTaxes = new Taxes();
                //objTaxes.CurrencyCode = "INR";
                //objTaxes.Amount = "888.31";
                //objTotal.Taxes = objTaxes;

                //BasicPropertyInfo objBasicPropertyInfo = new BasicPropertyInfo();
                //objBasicPropertyInfo.HotelCode = "00019853";

                //Comments objComments = new Comments();
                //Comment objComment = new Comment();
                //objComment.Text = "non-smoking room requested;king bed";
                //objComments.Comment = objComment;

                //objRoomStay.RoomTypes = objRoomTypes;
                //objRoomStay.RatePlans = objRatePlans;
                //objRoomStay.GuestCounts = objGuestCounts;
                //objRoomStay.TimeSpan = objTimeSpan;
                //objRoomStay.Total = objTotal;
                //objRoomStay.BasicPropertyInfo = objBasicPropertyInfo;
                //objRoomStay.Comments = objComments;
                //objRoomStays.RoomStay = objRoomStay;

                //ResGuests objResGuests = new ResGuests();
                //ResGuest objResGuest = new ResGuest();
                //Profiles objProfiles = new Profiles();
                //ProfileInfo objProfileInfo = new ProfileInfo();
                //Profile objProfile = new Profile();
                //objProfile.ProfileType = "1";
                //Customer objCustomer = new Customer();

                //PersonName objPersonName = new PersonName();
                //objPersonName.GivenName = "Desiya";
                //objPersonName.Surname = "Test";

                //Telephone objTelephone = new Telephone();
                //objTelephone.PhoneTechType = "1";
                //objTelephone.PhoneNumber = "1234567890";
                //objTelephone.CountryAccessCode = "91";

                //Address objAddress = new Address();

                //List<string> AddressLine = new System.Collections.Generic.List<string> { "Desia", "Malad" };
                //objAddress.AddressLine = AddressLine;
                //objAddress.CityName = "Mumbai";
                //objAddress.PostalCode = "400064";

                //StateProv objStateProv = new StateProv();
                //objStateProv.StateCode = "MH";
                //objStateProv.Text = "Maharastra";

                //CountryName objCountryName = new CountryName();
                //objCountryName.Code = "IN";
                //objCountryName.Text = "IN";

                //objAddress.StateProv = objStateProv;
                //objAddress.CountryName = objCountryName;

                //objCustomer.PersonName = objPersonName;
                //objCustomer.Telephone = objTelephone;
                //objCustomer.Email = "*****@*****.**";
                //objCustomer.Address = objAddress;

                //objProfile.Customer = objCustomer;

                //objProfileInfo.Profile = objProfile;

                //objProfiles.ProfileInfo = objProfileInfo;

                //objResGuest.Profiles = objProfiles;

                //objResGuests.ResGuest = objResGuest;

                //ResGlobalInfo objResGlobalInfo = new ResGlobalInfo();
                //Guarantee objGuarantee = new Guarantee();
                //objGuarantee.GuaranteeType = "PrePay";
                //objResGlobalInfo.Guarantee = objGuarantee;

                //objHotelReservation.RoomStays = objRoomStays;
                //objHotelReservation.ResGuests = objResGuests;
                //objHotelReservation.ResGlobalInfo = objResGlobalInfo;

                //objHotelReservations.HotelReservation = objHotelReservation;
                ////==> End

                //objOTA_HotelResRQ.POS = objPOS;
                //objOTA_HotelResRQ.UniqueID = objUniqueID;
                //objOTA_HotelResRQ.HotelReservations = objHotelReservations;
                //objOTA_HotelResRQ.Xmlns = "http://www.w3.org/2001/XMLSchema";
                //objOTA_HotelResRQ.Version = "0";
                //objOTA_HotelResRQ.CorrelationID = "1234587345";

                //objBody.OTA_HotelResRQ = objOTA_HotelResRQ;
                //objEnvelope.Body = objBody;

                //#region
                ////string xmlString = "";
                ////XmlSerializer xsSubmit = new XmlSerializer(typeof(Envelope));

                ////XmlWriterSettings settings = new XmlWriterSettings();
                ////settings.Encoding = new UnicodeEncoding(false, false); // no BOM in a .NET string
                ////settings.Indent = true;
                ////settings.OmitXmlDeclaration = true;

                ////XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
                ////// exclude xsi and xsd namespaces by adding the following:
                ////ns.Add(string.Empty, string.Empty);

                ////using (StringWriter textWriter = new StringWriter())
                ////{
                ////    using (XmlWriter xmlWriter = XmlWriter.Create(textWriter, settings))
                ////    {

                ////        xsSubmit.Serialize(xmlWriter, objEnvelope, ns);
                ////    }
                ////    xmlString = textWriter.ToString(); //This is the output as a string
                ////}
                ////#endregion

                #endregion Previous Code


                string xmlRequestBody = clsTravelGuruApi.ConvertToXmlString(objEnvelope);

                string status = clsTravelGuruApi.FetchBookingTravelGuruApi(xmlRequestBody);

                EnvelopePBRes objEnvelopeSHRes = clsTravelGuruApi.FromXml <EnvelopePBRes>(status);

                eProvisionalBookingResponseModel response = new eProvisionalBookingResponseModel();

                var apiResponse = objEnvelopeSHRes.Body.OTA_HotelResRS;

                if (apiResponse.Errors.Error != null)
                {
                    var error = apiResponse.Errors.Error;

                    // For Temperory booking Issue fix , Need to change once price mismatch issue will fix.
                    //if (error.Code == "083")
                    //{
                    //    var amountAfterTax = Convert.ToDecimal(apiResponse.HotelReservations.HotelReservation.RoomStays.RoomStay.Total.AmountAfterTax);
                    //    var taxAmount = Convert.ToDecimal(objTaxes.Amount);
                    //    objTotal.AmountBeforeTax = (amountAfterTax - taxAmount).ToString();

                    //    string xmlRequestBodyTemp = clsTravelGuruApi.ConvertToXmlString(objEnvelope);

                    //    string statusTemp = clsTravelGuruApi.FetchBookingTravelGuruApi(xmlRequestBodyTemp);

                    //    EnvelopePBRes objEnvelopeSHResTemp = clsTravelGuruApi.FromXml<EnvelopePBRes>(statusTemp);

                    //    eProvisionalBookingResponseModel responseTemp = new eProvisionalBookingResponseModel();

                    //    var tempResponse= objEnvelopeSHResTemp.Body.OTA_HotelResRS;

                    //    if (tempResponse != null)
                    //    {
                    //        var tempError = tempResponse.Errors.Error;
                    //        responseTemp.IsSuccedded = false;
                    //        responseTemp.ErrorCode = tempError.Code;
                    //        responseTemp.ErrorMessage = tempError.Text;

                    //    }

                    //    return responseTemp;

                    //}
                    response.IsSuccedded  = false;
                    response.ErrorCode    = error.Code;
                    response.ErrorMessage = error.Text ?? "An unknown error has happen!";
                }
                else
                {
                    response.IsSuccedded   = true;
                    response.CorrelationID = apiResponse.CorrelationID;
                    response.UniqueId      = apiResponse.HotelReservations.HotelReservation.UniqueID.ID;
                    response.UniqueIdType  = apiResponse.HotelReservations.HotelReservation.UniqueID.Type;
                }

                return(response);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }