private void ajaxSaveContract() { HttpContext.Current.Response.ContentType = "application/json"; List <ajaxContractFH.RequestDataJSON> requestDataJsonList = ajaxContractFH.JSONToObject <List <ajaxContractFH.RequestDataJSON> >(HttpUtility.UrlDecode(new StreamReader(HttpContext.Current.Request.InputStream).ReadToEnd())); ajaxContractFH.RequestDataJSON requestDataJson1 = new ajaxContractFH.RequestDataJSON(); try { UserContract list = new UserContract(); list.Type = 1; list.ParentId = Convert.ToInt32(this.AdminId); list.UserId = Convert.ToInt32(requestDataJsonList[0].userId); List <UserContractDetail> userContractDetailList = new List <UserContractDetail>(); for (int index = 0; index < requestDataJsonList.Count; ++index) { ajaxContractFH.RequestDataJSON requestDataJson2 = requestDataJsonList[index]; userContractDetailList.Add(new UserContractDetail() { MinMoney = Convert.ToDecimal(requestDataJson2.money), Money = Convert.ToDecimal(requestDataJson2.per) }); } list.UserContractDetails = userContractDetailList; this._response = new ContractDAL().SaveContract(list) <= 0 ? this.JsonResult(0, "分配契约失败!") : this.JsonResult(1, "分配契约成功!"); } catch (Exception ex) { this._response = this.JsonResult(0, "分配契约失败!"); } }
private void ajaxSaveContract() { HttpContext.Current.Response.ContentType = "application/json"; List <ajaxContractFH.RequestDataJSON> requestDataJsonList = ajaxContractFH.JSONToObject <List <ajaxContractFH.RequestDataJSON> >(HttpUtility.UrlDecode(new StreamReader(HttpContext.Current.Request.InputStream).ReadToEnd())); ajaxContractFH.RequestDataJSON requestDataJson1 = new ajaxContractFH.RequestDataJSON(); try { int adminId = Int32.Parse(this.AdminId); if ((new Lottery.DAL.Flex.UserDAL()).IsAdminUser(adminId) || (new UserContractDAL()).HasUsedContract(Int32.Parse(this.AdminId), 1)) { UserContract list = new UserContract(); list.Type = 1; list.ParentId = Convert.ToInt32(this.AdminId); list.UserId = Convert.ToInt32(requestDataJsonList[0].userId); List <UserContractDetail> userContractDetailList = new List <UserContractDetail>(); for (int index = 0; index < requestDataJsonList.Count; ++index) { ajaxContractFH.RequestDataJSON requestDataJson2 = requestDataJsonList[index]; UserContractDetail detail = new UserContractDetail() { MinMoney = Convert.ToDecimal(requestDataJson2.money), Money = Convert.ToDecimal(requestDataJson2.per) }; if (detail.MinMoney <= 0 || detail.Money <= 0) { throw new Exception("输入的数值无效"); } userContractDetailList.Add(detail); } list.UserContractDetails = userContractDetailList; this._response = new ContractDAL().SaveContract(list) <= 0 ? this.JsonResult(0, "分配契约失败!") : this.JsonResult(1, "分配契约成功!"); } else { this._response = this.JsonResult(0, "会员暂无权限分配契约!"); } } catch (Exception ex) { this._response = this.JsonResult(0, "分配契约失败!"); } }
private void ajaxSaveContract() { HttpContext.Current.Response.ContentType = "application/json"; HttpRequest request = HttpContext.Current.Request; StreamReader streamReader = new StreamReader(request.InputStream); string str = streamReader.ReadToEnd(); string jsonText = HttpUtility.UrlDecode(str); List <ajaxContractFH.RequestDataJSON> list = ajaxContractFH.JSONToObject <List <ajaxContractFH.RequestDataJSON> >(jsonText); ajaxContractFH.RequestDataJSON requestDataJSON = new ajaxContractFH.RequestDataJSON(); try { UserContract userContract = new UserContract(); userContract.Type = 1; userContract.ParentId = Convert.ToInt32(this.AdminId); userContract.UserId = Convert.ToInt32(list[0].userId); List <UserContractDetail> list2 = new List <UserContractDetail>(); for (int i = 0; i < list.Count; i++) { requestDataJSON = list[i]; list2.Add(new UserContractDetail { MinMoney = Convert.ToDecimal(requestDataJSON.money), Money = Convert.ToDecimal(requestDataJSON.per) }); } userContract.UserContractDetails = list2; if (new ContractDAL().SaveContract(userContract) > 0) { this._response = base.JsonResult(1, "分配契约成功!"); } else { this._response = base.JsonResult(0, "分配契约失败!"); } } catch { this._response = base.JsonResult(0, "分配契约失败!"); } }