/// <summary> /// 保存额度核销数据 /// </summary> /// <returns>返回Json串</returns> public string SaveHX() { string adddata = System.Web.HttpContext.Current.Request.Params["adddata"]; string updatedata = System.Web.HttpContext.Current.Request.Params["updatedata"]; string deletedata = System.Web.HttpContext.Current.Request.Params["deletedata"]; var addinfo = JsonConvert.DeserializeObject <List <ExpenseHxModel> >(adddata); var updateinfo = JsonConvert.DeserializeObject <List <ExpenseHxModel> >(updatedata); var deleteinfo = JsonConvert.DeserializeObject <List <string> >(deletedata); CommonResult savedresult = new CommonResult(); savedresult = ExpenseMstService.SaveHX(addinfo, updateinfo, deleteinfo); return(DataConverterHelper.SerializeObject(savedresult)); }
public string PostSaveHX([FromBody] BaseInfoModel <List <ExpenseHxModel> > param) { if (param.infoData == null) { return(DCHelper.ErrorMessage("保存的数据不能为空!")); } try { var addinfo = new List <ExpenseHxModel>(); var updateinfo = new List <ExpenseHxModel>(); var deleteinfo = new List <string>(); foreach (ExpenseHxModel a in param.infoData) { if (a.PhId == 0) { a.PersistentState = PersistentState.Added; addinfo.Add(a); } else { if (a.PersistentState == PersistentState.Deleted) { deleteinfo.Add(a.PhId.ToString()); } else { a.PersistentState = PersistentState.Modified; updateinfo.Add(a); } } } CommonResult savedresult = new CommonResult(); savedresult = ExpenseMstService.SaveHX(addinfo, updateinfo, deleteinfo); return(DataConverterHelper.SerializeObject(savedresult)); } catch (Exception ex) { return(DCHelper.ErrorMessage(ex.Message)); } }