public virtual Task <AjaxResult> ModifyRangeDic(string jsonArray, ServerCallContext context) { var request = JsonHelper.ToObject <List <Dictionary <string, string> > >(jsonArray); //拿到对象并根据字典进行相关字典修改 var entityList = baseService().FindAll(m => request.Select(s => Convert.ToInt32(s["ID"])).Contains(m.ID)).Result; entityList.ForEach(mEntity => { var curDic = request.Where(d => Convert.ToInt32(d["ID"]) == mEntity.ID).First(); EntityAutoMapper.ConvertMappintDic(mEntity, curDic, false); }); AjaxResult result = new AjaxResult(); return(Task.Run <AjaxResult>(() => { if (baseService().UpdateRange(entityList).Result) { result.Result = DoResult.Success; result.NumberMsg = 3010; } else { result.Result = DoResult.Failed; result.NumberMsg = 3011; } return result; })); }
public virtual Task <AjaxResult> ModifyDic(Dictionary <string, string> request, ServerCallContext context) { //拿到对象并根据字典进行相关字典修改 M mEntity = baseService().Find(Convert.ToInt32(request["ID"])).Result; EntityAutoMapper.ConvertMappintDic(mEntity, request, false); AjaxResult result = new AjaxResult(); var validRes = this.ValidAdd_Modify(mEntity, context).Result; return(Task.Run <AjaxResult>(() => { if (validRes == "1") { if (baseService().Update(mEntity).Result) { result.Result = DoResult.Success; result.NumberMsg = 3010; } else { result.Result = DoResult.Failed; result.NumberMsg = 3011; } } else { result.Result = DoResult.ValidError; result.NumberMsg = Convert.ToInt32(validRes); } return result; })); }