コード例 #1
0
        /// <summary>
        /// Add a customer charge for a customer
        /// </summary>
        /// <param name="customCharge">A CustomerChargePost object with the customer charge and customer code</param>
        /// <returns>A Customer object with the reflected custom charge</returns>
        public static Customer AddCustomCharge(CustomChargePost customCharge)
        {
            Customers customers    = new Customers();
            Customer  editCustomer = new Customer();

            try
            {
                string urlBase    = "https://cheddargetter.com/xml";
                string urlPath    = string.Format("/customers/set-item-quantity/productCode/{0}/code/{1}/itemCode/{2}", _ProductCode, customCharge.CustomerCode, customCharge.ItemCode);
                string postParams = string.Format(
                    "chargeCode={0}" +
                    "&quantity={1}" +
                    "&eachAmount={2}" +
                    "&description={3}",
                    HttpUtility.UrlEncode(customCharge.ChargeCode),
                    HttpUtility.UrlEncode(customCharge.Quantity.ToString()),
                    HttpUtility.UrlEncode(customCharge.EachAmount.ToString()),
                    HttpUtility.UrlEncode(customCharge.Description));

                string    result         = postRequest(urlBase, urlPath, postParams);
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    editCustomer = customers.CustomerList[0];
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(editCustomer);
        }
コード例 #2
0
        /// <summary>
        /// Add a customer charge for a customer
        /// </summary>
        /// <param name="customCharge">A CustomerChargePost object with the customer charge and customer code</param>
        /// <returns>A Customer object with the reflected custom charge</returns>
        public static Customer AddCustomCharge(CustomChargePost customCharge)
        {
            Customers customers = new Customers();
            Customer editCustomer = new Customer();

            try
            {
                string urlBase = "https://cheddargetter.com/xml";
                string urlPath = string.Format("/customers/set-item-quantity/productCode/{0}/code/{1}/itemCode/{2}", _ProductCode, customCharge.CustomerCode, customCharge.ItemCode);
                string postParams = string.Format(
                  "chargeCode={0}" +
                  "&quantity={1}" +
                  "&eachAmount={2}" +
                  "&description={3}",
                  HttpUtility.UrlEncode(customCharge.ChargeCode),
                  HttpUtility.UrlEncode(customCharge.Quantity.ToString()),
                  HttpUtility.UrlEncode(customCharge.EachAmount.ToString()),
                  HttpUtility.UrlEncode(customCharge.Description));

                string result = postRequest(urlBase, urlPath, postParams);
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    editCustomer = customers.CustomerList[0];
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }

            return editCustomer;
        }