public static TG_ProvisionalBookingResponseModel ProvisionalBooking(TG_ProvisionalBookingRequestModel model) { TGBookingService.TGBookingServiceEndPointImplService bookingService = new TGBookingService.TGBookingServiceEndPointImplService(); TGBookingService.OTA_HotelResRQ hotelResRQ = new TGBookingService.OTA_HotelResRQ(); hotelResRQ.CorrelationID = model.CorrelationID; hotelResRQ.POS = new TGBookingService.SourceType[1]; hotelResRQ.POS[0] = new TGBookingService.SourceType(); hotelResRQ.POS[0].ISOCurrency = model.Currency; hotelResRQ.POS[0].RequestorID = new TGBookingService.SourceTypeRequestorID(); hotelResRQ.POS[0].RequestorID.ID = model.API_Credential_PropertyId; hotelResRQ.POS[0].RequestorID.MessagePassword = model.API_Credential_Password; hotelResRQ.POS[0].RequestorID.CompanyName = new TGBookingService.CompanyNameType(); hotelResRQ.POS[0].RequestorID.CompanyName.Code = model.API_Credential_UserName; hotelResRQ.UniqueID = new TGBookingService.UniqueID_Type[1]; hotelResRQ.UniqueID[0] = new TGBookingService.UniqueID_Type(); hotelResRQ.UniqueID[0].Type = model.UniqueIdType; hotelResRQ.UniqueID[0].ID = model.UniqueId; hotelResRQ.HotelReservations = new TGBookingService.HotelReservationsType(); for (int h = 0; h < 1; h++) { hotelResRQ.HotelReservations.HotelReservation = new TGBookingService.HotelReservationsTypeHotelReservation[1]; hotelResRQ.HotelReservations.HotelReservation[h] = new TGBookingService.HotelReservationsTypeHotelReservation(); for (int rs = 0; rs < 1; rs++) { hotelResRQ.HotelReservations.HotelReservation[h].RoomStays = new TGBookingService.RoomStaysTypeRoomStay[1]; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0] = new TGBookingService.RoomStaysTypeRoomStay(); hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].RoomTypes = new TGBookingService.RoomTypeType[1]; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].RoomTypes[0] = new TGBookingService.RoomTypeType(); hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].RoomTypes[0].NumberOfUnits = model.NumberOfRooms; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].RoomTypes[0].RoomTypeCode = model.RoomTypeCode; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].RatePlans = new TGBookingService.RatePlanType[1]; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].RatePlans[0] = new TGBookingService.RatePlanType(); hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].RatePlans[0].RatePlanCode = model.RatePlanCode; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].GuestCounts = new TGBookingService.GuestCountType(); hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].GuestCounts.IsPerRoom = false; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].GuestCounts.IsPerRoomSpecified = true; List <TGBookingService.GuestCountTypeGuestCount> guestCountList = new List <TGBookingService.GuestCountTypeGuestCount>(); foreach (var room in model.RoomData) { var adultDetail = new TGBookingService.GuestCountTypeGuestCount(); adultDetail.AgeQualifyingCode = "10"; adultDetail.Count = room.adult; adultDetail.CountSpecified = true; adultDetail.ResGuestRPH = room.room.ToString(); guestCountList.Add(adultDetail); foreach (var child in room.ChildAge) { var childDetail = new TGBookingService.GuestCountTypeGuestCount(); childDetail.AgeQualifyingCode = "8"; childDetail.AgeSpecified = true; childDetail.Count = 1; childDetail.CountSpecified = true; childDetail.Age = int.Parse(child.Age); childDetail.ResGuestRPH = room.room.ToString(); guestCountList.Add(childDetail); } } hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].GuestCounts.GuestCount = guestCountList.ToArray(); hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].TimeSpan = new TGBookingService.DateTimeSpanType(); hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].TimeSpan.Start = model.CheckIn; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].TimeSpan.End = model.CheckOut; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].Total = new TGBookingService.TotalType(); hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].Total.AmountBeforeTaxSpecified = true; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].Total.AmountBeforeTax = decimal.Parse(model.AmountBeforeTax) + decimal.Parse(model.ExtraBedCharge); hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].Total.CurrencyCode = model.Currency; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].Total.Taxes = new TGBookingService.TaxesType(); hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].Total.Taxes.Amount = decimal.Parse(model.TaxAmount); hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].Total.Taxes.AmountSpecified = true; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].Total.Taxes.CurrencyCode = model.Currency; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].BasicPropertyInfo = new TGBookingService.BasicPropertyInfoType(); hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].BasicPropertyInfo.HotelCode = model.HotelCode; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].Comments = new TGBookingService.CommentTypeComment[1]; hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].Comments[0] = new TGBookingService.CommentTypeComment(); hotelResRQ.HotelReservations.HotelReservation[h].RoomStays[0].Comments[0].Name = "Provisional Hotel Booking"; } hotelResRQ.HotelReservations.HotelReservation[h].ResGuests = new TGBookingService.ResGuestType[1]; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0] = new TGBookingService.ResGuestType(); hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles = new TGBookingService.ProfilesTypeProfileInfo[1]; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0] = new TGBookingService.ProfilesTypeProfileInfo(); hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile = new TGBookingService.ProfileType(); hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.ProfileType1 = model.ProfileType; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer = new TGBookingService.CustomerType(); hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.PersonName = new TGBookingService.PersonNameType[1]; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.PersonName[0] = new TGBookingService.PersonNameType(); hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.PersonName[0].NamePrefix = new string[] { model.CustomerNamePrefix }; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Email = new TGBookingService.CustomerTypeEmail[1]; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Email[0] = new TGBookingService.CustomerTypeEmail(); hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Email[0].Value = model.CustomerEmail; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.PersonName[0].GivenName = new string[] { model.CustomerGivenName }; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.PersonName[0].Surname = model.CustomerSurname; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Telephone = new TGBookingService.CustomerTypeTelephone[1]; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Telephone[0] = new CustomerTypeTelephone(); hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Telephone[0].CountryAccessCode = model.CountryAccessCode; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Telephone[0].PhoneTechType = model.PhoneTechType; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Telephone[0].PhoneNumber = model.PhoneNumber; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Telephone[0].AreaCityCode = model.AreaCityCode; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Telephone[0].DefaultInd = true; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Telephone[0].DefaultIndSpecified = true; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Address = new TGBookingService.CustomerTypeAddress[1]; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Address[0] = new TGBookingService.CustomerTypeAddress(); hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Address[0].AddressLine = model.AddressLine.ToArray(); hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Address[0].CityName = model.CityName; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Address[0].PostalCode = model.PostalCode; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Address[0].StateProv = new TGBookingService.StateProvType(); hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Address[0].StateProv.StateCode = model.StateCode; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Address[0].StateProv.Value = model.StateCode; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Address[0].CountryName = new TGBookingService.CountryNameType(); hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Address[0].CountryName.Code = model.CountryCode; hotelResRQ.HotelReservations.HotelReservation[h].ResGuests[0].Profiles[0].Profile.Customer.Address[0].CountryName.Value = model.CountryName; hotelResRQ.HotelReservations.HotelReservation[h].ResGlobalInfo = new TGBookingService.ResGlobalInfoType(); hotelResRQ.HotelReservations.HotelReservation[h].ResGlobalInfo.Guarantee = new TGBookingService.GuaranteeType(); hotelResRQ.HotelReservations.HotelReservation[h].ResGlobalInfo.Guarantee.GuaranteeType1 = model.GuaranteeType; } var response = bookingService.createBooking(hotelResRQ); TG_ProvisionalBookingResponseModel responseModel = null; if (response != null) { responseModel = new TG_ProvisionalBookingResponseModel(); if (response.Errors != null && response.Errors.Count() > 0) { responseModel.IsSuccedded = false; var error = response.Errors.FirstOrDefault(); responseModel.ErrorCode = error.Code; responseModel.ErrorMessage = error.ShortText; responseModel.ErrorType = error.Type; } else if (response.HotelReservations != null && response.HotelReservations.HotelReservation != null) { var reservation = response.HotelReservations.HotelReservation.FirstOrDefault(); var uniqueDetails = reservation.UniqueID.FirstOrDefault(); responseModel.UniqueId = uniqueDetails.ID; responseModel.UniqueIdType = uniqueDetails.Type; responseModel.CorrelationID = response.CorrelationID; responseModel.IsSuccedded = true; } } //var requestXml = ToXML(hotelResRQ); //var responseXml = ToXML(response); return(responseModel); }
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; } }