public void ProcessRequest(HttpContext context) { string typeId = context.Request["type_id"]; if (string.IsNullOrEmpty(typeId)) { apiResp.code = 1; apiResp.msg = "type_id 为必填项,请检查"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } ZentCloud.BLLJIMP.Model.TypeInfo model = bll.Get <ZentCloud.BLLJIMP.Model.TypeInfo>(string.Format(" WebSiteOwner='{0}' AND TypeId={1} ", bll.WebsiteOwner, typeId)); if (model == null) { apiResp.code = 1; apiResp.msg = "没有找到信息"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } apiResp.status = true; apiResp.msg = "ok"; apiResp.result = new { type_id = model.TypeId, type_name = model.TypeName }; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; }
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.type_id == 0) { apiResp.code = 1; apiResp.msg = "type_id 为必填项,请检查"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } if (string.IsNullOrEmpty(requestModel.type_name)) { apiResp.code = 1; apiResp.msg = "type_name 为必填项,请检查"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } ZentCloud.BLLJIMP.Model.TypeInfo model = bll.Get <ZentCloud.BLLJIMP.Model.TypeInfo>(string.Format(" WebsiteOwner='{0}' And TypeId={1}", bll.WebsiteOwner, requestModel.type_id)); model.TypeName = requestModel.type_name; if (bll.Update(model)) { apiResp.status = true; apiResp.msg = "ok"; } else { apiResp.msg = "编辑失败"; apiResp.code = (int)APIErrCode.OperateFail; } context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); }
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 (string.IsNullOrEmpty(requestModel.type_name)) { apiResp.code = 1; apiResp.msg = "type_name 为必填项,请检查"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } ZentCloud.BLLJIMP.Model.TypeInfo model = new ZentCloud.BLLJIMP.Model.TypeInfo(); model.TypeId = int.Parse(bll.GetGUID(BLLJIMP.TransacType.CommAdd)); model.TypeName = requestModel.type_name; model.WebsiteOwner = bll.WebsiteOwner; model.InsertDate = DateTime.Now; if (bll.Add(model)) { apiResp.status = true; apiResp.msg = "ok"; } else { apiResp.msg = "添加失败"; apiResp.code = (int)APIErrCode.OperateFail; } context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); }