public ActionResult EditChartTemp(long?id) { var entObj = new ChartTempModel();//初始化基础数据 if (id != null && id != 0) { entObj = _ChartAppService.GetChartTemp(id.Value); } entObj.ChartTypeList = _ChartAppService.ChartTypeSelectList(); return(View(entObj)); }
/// <summary> /// 更新和新增图表模版 /// </summary> /// <param name="input"></param> /// <returns></returns> public ChartTempModel InsertOrUpdateChartTemp(ChartTempModel input) { if (_ChartTempCase.GetAll().Any(p => p.Id != input.Id && p.Name == input.Name)) { throw new UserFriendlyException("名为【" + input.Name + "】的对象已存在!"); } var entObj = input.MapTo <ChartTemp>(); //var entObj= AutoMapper.Mapper.Map<ChartTemp>(input); var resObj = _ChartTempCase.InsertOrUpdate(entObj); if (resObj == null) { throw new UserFriendlyException("新增或更新失败!"); } else { return(resObj.MapTo <ChartTempModel>()); } }