public void ProcessRequest(HttpContext context) { string data = context.Request["data"]; RequestModel requestModel; try { requestModel = ZentCloud.Common.JSONHelper.JsonToModel <RequestModel>(context.Request["data"]); } catch (Exception) { apiResp.code = -1; apiResp.msg = "json格式错误,请检查"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } if (requestModel.config_list == null || requestModel.config_list == null) { apiResp.code = -1; apiResp.msg = "配置不能为空,请检查"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction(); try { foreach (var item in requestModel.config_list) { ProductPriceConfig model = new ProductPriceConfig(); model.WebsiteOwner = bllMall.WebsiteOwner; model.Date = item.date; model.Price = item.price; model.ProductId = item.product_id; model.SkuId = item.sku_id; if (!bllMall.Add(model)) { tran.Rollback(); apiResp.code = -1; apiResp.msg = "操作失败"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } } tran.Commit(); apiResp.msg = "ok"; } catch (Exception ex) { tran.Rollback(); apiResp.code = -1; apiResp.msg = ex.Message; } context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); }
public void ProcessRequest(HttpContext context) { string id = context.Request["id"]; string productId = context.Request["product_id"]; string date = context.Request["date"]; string price = context.Request["price"]; ProductPriceConfig model = bllMall.Get <ProductPriceConfig>(string.Format(" AutoId={0} And WebsiteOwner='{1}'", id, bllMall.WebsiteOwner)); model.ProductId = productId; model.Date = date; model.Price = decimal.Parse(price); if (bllMall.Update(model)) { apiResp.status = true; apiResp.msg = "ok"; } else { apiResp.code = -1; apiResp.msg = "操作失败"; } context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); }