Пример #1
0
        public async Task <JsonResult> SaveSysDictCodeModel(List <SysDictInput> sysDictInput)
        {
            //保存字典编码值
            var ajaxResponse = await _sysDictAppService.SaveSysDictModel(sysDictInput);

            return(Json(ajaxResponse));
        }
Пример #2
0
        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 }
            });
        }