コード例 #1
0
        /// <summary>
        /// 5. Add voucher
        /// </summary>
        /// <param name="token"></param>
        /// <param name="VoucherNo"></param>
        /// <returns></returns>
        private decimal AddVoucher(string token, string VoucherNo)
        {
            decimal reservationBalance = 0;
            using (BookingTPAPIService.RadixxBooking client = new BookingTPAPIService.RadixxBooking())
            {
                var response = client.ResAddVoucher(token, VoucherNo);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(response);
                XmlNode voucherXML = doc.SelectSingleNode("/ReservationBO/Reservation/Vouchers/Voucher[VoucherNumberFull='" + VoucherNo + "'][IsNew='true'][last()]");

                var voucherPaymentId = int.Parse(voucherXML.SelectSingleNode("VoucherNumber").InnerText);

                reservationBalance = decimal.Parse(doc.SelectSingleNode("/ReservationBO/Reservation/ReservationBalance").InnerText, System.Globalization.CultureInfo.InvariantCulture);

            }
            return reservationBalance;
        }
コード例 #2
0
        /// <summary>
        /// 4. Get voucher information
        /// </summary>
        /// <param name="token"></param>
        /// <param name="VoucherNo"></param>
        /// <returns></returns>
        public List<Voucher> GetVoucherInfo(string token, string VoucherNo)
        {
            var vouchers = new List<Voucher>();
            string voucherString =
                    string.Format("<VoucherRequests><VoucherRequest><VoucherNumber>{0}</VoucherNumber></VoucherRequest></VoucherRequests>",
                        VoucherNo);

            using (BookingTPAPIService.RadixxBooking client = new BookingTPAPIService.RadixxBooking())
            {
                var response = client.GetVoucherInfo(token, voucherString);
                var doc = new XmlDocument();
                doc.LoadXml(response);
                var namespaceManager = new XmlNamespaceManager(doc.NameTable);
                namespaceManager.AddNamespace("radixx", "http://tempuri.org/VouchersResponse.xsd");

                foreach (XmlNode node in doc.SelectNodes("/radixx:VoucherResponses/radixx:VoucherResponse", namespaceManager))
                {
                    if (node.SelectSingleNode("radixx:NotFound", namespaceManager).InnerText == "false")
                    {
                        vouchers.Add(new Voucher
                        {
                            BalanceAmount = decimal.Parse(node.SelectSingleNode("radixx:BalanceAmount", namespaceManager).InnerText, System.Globalization.CultureInfo.InvariantCulture),
                            VoucherPW = node.SelectSingleNode("radixx:VoucherPW", namespaceManager).InnerText,
                            VoucherNumFull = node.SelectSingleNode("radixx:VoucherNumberFull", namespaceManager).InnerText
                        });

                    }
                }
            }
            return vouchers;
        }