public HttpResponseMessage UpdateProductQuantity(ProductQuantityParam data)
        {
            string content = this._updateProductQuantity(data);

            return(new HttpResponseMessage
            {
                Content = new StringContent(content, Encoding.UTF8, "application/json")
            });
        }
 private bool CheckUpdateQuantityParameters(ProductQuantityParam parameter, out string result)
 {
     if (!OpenApiHelper.CheckSystemParameters(parameter.app_key, parameter.timestamp, parameter.sign, out result))
     {
         return(false);
     }
     if (parameter.num_iid <= 0)
     {
         result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Parameters_Format_Error, "num_iid");
         return(false);
     }
     return(true);
 }
        private string lastUpdateProductQuantity(ProductQuantityParam param)
        {
            ProductApiDao      productApiDao = new ProductApiDao();
            product_item_model product       = productApiDao.GetProduct(param.num_iid);

            if (product == null)
            {
                return(OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Product_Not_Exists, "num_iid"));
            }
            if (productApiDao.UpdateProductQuantity(param.num_iid, param.sku_id, param.quantity, param.type) <= 0)
            {
                return(OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Product_UpdateeQuantity_Faild, "update_quantity"));
            }
            product.props_name = productApiDao.GetProps(param.num_iid);
            product.skus       = productApiDao.GetSkus(param.num_iid);
            string format = "{{\"product_get_response\":{{\"item\":{0}}}}}";

            return(string.Format(format, JsonConvert.SerializeObject(product)));
        }
        public HttpResponseMessage UpdateProductQuantity()
        {
            NameValueCollection  nameValueCollection  = base.Request.RequestUri.ParseQueryString();
            ProductQuantityParam productQuantityParam = new ProductQuantityParam();

            if (nameValueCollection.AllKeys.Contains("app_key"))
            {
                productQuantityParam.app_key = nameValueCollection["app_key"];
            }
            if (nameValueCollection.AllKeys.Contains("timestamp"))
            {
                productQuantityParam.timestamp = nameValueCollection["timestamp"];
            }
            if (nameValueCollection.AllKeys.Contains("sign"))
            {
                productQuantityParam.sign = nameValueCollection["sign"];
            }
            if (nameValueCollection.AllKeys.Contains("num_iid"))
            {
                productQuantityParam.num_iid = Convert.ToInt32(nameValueCollection["num_iid"]);
            }
            if (nameValueCollection.AllKeys.Contains("sku_id"))
            {
                productQuantityParam.sku_id = nameValueCollection["sku_id"];
            }
            if (nameValueCollection.AllKeys.Contains("quantity"))
            {
                productQuantityParam.quantity = Convert.ToInt32(nameValueCollection["quantity"]);
            }
            if (nameValueCollection.AllKeys.Contains("type"))
            {
                productQuantityParam.type = Convert.ToInt32(nameValueCollection["type"]);
            }
            string content = this._updateProductQuantity(productQuantityParam);

            return(new HttpResponseMessage
            {
                Content = new StringContent(content, Encoding.UTF8, "application/json")
            });
        }
        private string _updateProductQuantity(ProductQuantityParam data)
        {
            string result = "";

            if (this.CheckUpdateQuantityParameters(data, out result))
            {
                SiteSettings siteSettings = HiContext.Current.SiteSettings;
                string       text         = OpenApiSign.Sign(data.SignStr(siteSettings.CheckCode), "MD5", "utf-8");
                if (text.Equals(data.sign))
                {
                    if (data.type == 0)
                    {
                        data.type = 1;
                    }
                    result = this.lastUpdateProductQuantity(data);
                }
                else
                {
                    result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Invalid_Signature, "sign");
                }
            }
            return(result);
        }