public async Task <JsonResult> SaveSysDictTypeModel(SysDictTypeInput modelInput) { //保存字典类型值 var ajaxResponse = await _sysDictTypeAppService.SaveSysDictTypeModel(modelInput); return(Json(ajaxResponse)); }
public JsonResult DelSysDictType(SysDictTypeInput model) { if (model.Id == null) { return(Json(false)); } //删除字典类型数据 _sysDictTypeAppService.DelSysDictType(model); return(Json(true)); }
public async Task <AjaxResponse> SaveSysDictTypeModel(SysDictTypeInput model) { Guid?resId; //验证重复 if (CheckDictCode(model)) { return(new AjaxResponse { Success = false, Error = new ErrorInfo("您设置的字典类型值" + model.DictType + "重复!") }); //throw new UserFriendlyException("字典类型值重复", "您设置的字典类型值" + model.DictType + "重复!"); } //新增或修改 if (model.Id == null) { SysDictType modelInput = model.MapTo <SysDictType>(); resId = await _sysDicTypetRepository.InsertAndGetIdAsync(modelInput); } else { //获取需要更新的数据 SysDictType data = _sysDicTypetRepository.Get((Guid)model.Id); //映射需要修改的数据对象 SysDictType m = ObjectMapper.Map(model, data); //提交修改 await _sysDicTypetRepository.UpdateAsync(m); resId = model.Id; } //保存字典编码 if (model.SysDictInputList != null) { AjaxResponse res = await _sysDictAppService.SaveSysDictModel(model.SysDictInputList); if (!res.Success) { return(res); } } return(new AjaxResponse { Success = true, Result = new { id = resId } }); }
public void DelSysDictType(SysDictTypeInput model) { if (model.Id == null) { return; } var dictType = _sysDicTypetRepository.GetAllList().Where(p => p.Id == model.Id); if (!dictType.Any()) { throw new UserFriendlyException("删除字典类型失败", "字典类型不存在!"); } //删除字典类型 _sysDicTypetRepository.Delete(model.Id.Value); //删除字典编码 _sysDictAppService.DeleteSysDictByDictType(model.DictType); }
public bool CheckDictCode(SysDictTypeInput model) { var data = _sysDicTypetRepository.FirstOrDefault(p => p.DictType == model.DictType && p.Id != model.Id); return(data == null ? false : true); }