/// <summary> /// 批量操作 /// </summary> /// <param name="models"></param> /// <returns></returns> public JsonResult SaveCityAgingBulk(List <CityAgingModel> models) { var result = new MJsonResult() { Status = true }; try { if (models == null) { result.Status = false; result.Msg = "数据不能为空!"; return(Json(result)); } var returnValue = 0; var operatorsUserName = ThreadIdentity.Operator.Name; //批量查询修改前的历史数据 var tableDatas = CityAgingManage.SelectCityAgingInfoByIds(models.Select(t => t.PKid).ToList()); foreach (CityAgingModel model in models) { if (model.PKid == -1) //还没有修改过时效性 { returnValue = CityAgingManage.CreateSelectCityAging(model.CityId, model.CityName, model.IsShow, model.Title, model.Content, operatorsUserName); } else { model.UpdateUser = operatorsUserName; returnValue = CityAgingManage.UpdateSelectCityAging(model.PKid, model.IsShow, model.Title, model.Content, operatorsUserName); } var beforvalue = new CityAgingModel(); if (tableDatas != null && tableDatas.Any()) { beforvalue = tableDatas.Where(t => t.PKid == model.PKid).FirstOrDefault(); } else { beforvalue = null; } if (returnValue > 0) { SaveLog(beforvalue, model); } } } catch (Exception e) { result.Status = false; result.Msg = "异常:" + e.Message; } return(Json(result)); }
/// <summary> /// 保存时效信息 /// </summary> /// <returns></returns> public JsonResult SaveCityAging(CityAgingModel model) { var result = new MJsonResult() { Status = true }; try { var returnValue = 0; if (model == null) { result.Status = false; result.Msg = "model 不能为空!"; return(Json(result)); } var operatorsUserName = ThreadIdentity.Operator.Name; var beforvalue = new CityAgingModel(); if (model.PKid != -1) { var tableData = CityAgingManage.SelectCityAgingInfoByIds(new List <int>() { model.PKid }); if (tableData != null && tableData.Any()) { beforvalue = tableData.FirstOrDefault(); } else { beforvalue = null; } } else { beforvalue = null; } if (model.PKid == -1) { returnValue = CityAgingManage.CreateSelectCityAging(model.CityId, model.CityName, model.IsShow, model.Title, model.Content, operatorsUserName); } else { model.UpdateUser = operatorsUserName; returnValue = CityAgingManage.UpdateSelectCityAging(model.PKid, model.IsShow, model.Title, model.Content, operatorsUserName); } if (returnValue > 0) { SaveLog(beforvalue, model); result.Status = true; result.Msg = "保存成功!"; } else { result.Status = false; result.Msg = "保存失败!"; } } catch (Exception e) { result.Status = false; result.Msg = "异常:" + e.Message; } return(Json(result)); }