/// <summary> /// Set an item count to a specific quantity /// </summary> /// <param name="customerCode">The customer's code of the customer that will be updated </param> /// <param name="itemCode">The code of the item that will be updated</param> /// <param name="quantityToSet">The quantity to set for the item</param> /// <returns>A Customer object reflecting the updated item and quantity count</returns> public static Customer SetItem(string customerCode, ProductItemCode itemCode, int quantityToSet) { 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, customerCode, itemCode.ToString()); string postParams = string.Format("quantity={0}", HttpUtility.UrlEncode(quantityToSet.ToString())); 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); }
/// <summary> /// Set an item count to a specific quantity /// </summary> /// <param name="customerCode">The customer's code of the customer that will be updated </param> /// <param name="itemCode">The code of the item that will be updated</param> /// <param name="quantityToSet">The quantity to set for the item</param> /// <returns>A Customer object reflecting the updated item and quantity count</returns> public async Task <Customer> SetItem(string customerCode, ProductItemCode itemCode, int quantityToSet) { Customers customers = new Customers(); Customer editCustomer = new Customer(); try { string urlPath = $"/customers/set-item-quantity/productCode/{_config.productCode}/code/{customerCode}/itemCode/{itemCode.ToString()}"; string postParams = $"quantity={WebUtility.UrlEncode(quantityToSet.ToString())}"; string result = await _httpService.postRequest(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); }
/// <summary> /// Set an item count to a specific quantity /// </summary> /// <param name="customerCode">The customer's code of the customer that will be updated </param> /// <param name="itemCode">The code of the item that will be updated</param> /// <param name="quantityToSet">The quantity to set for the item</param> /// <returns>A Customer object reflecting the updated item and quantity count</returns> public static Customer SetItem(string customerCode, ProductItemCode itemCode, int quantityToSet) { 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, customerCode, itemCode.ToString()); string postParams = string.Format("quantity={0}", HttpUtility.UrlEncode(quantityToSet.ToString())); 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; }