Ejemplo n.º 1
0
        public IActionResult Create(DictTypeModel model)
        {
            var response = new ResponseResult <bool>();

            using (_dbContext)
            {
                if (_dbContext.SysDictType.Count(a => a.DictName == model.DictName) > 0)
                {
                    return(Ok(response.Error(ResponseCode.ERROR, "该名称已存在")));
                }
                if (_dbContext.SysDictType.Count(a => a.DictType == model.DictType) > 0)
                {
                    return(Ok(response.Error(ResponseCode.ERROR, "该标识已存在")));
                }
                var mapConfig = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <string, int?>().ConvertUsing(new NullableIntUtcTimeTypeConverter());
                    cfg.CreateMap <string, DateTime?>().ConvertUsing(new NullableUtcTimeTypeConverter());
                    cfg.CreateMap <DictTypeModel, SysDictType>();
                });
                //mapConfig.AssertConfigurationIsValid();
                var entity = model.MapTo <DictTypeModel, SysDictType>(mapConfig);
                _dbContext.Add(entity);
                int result = _dbContext.SaveChanges();
                if (result > 0)
                {
                    return(Ok(response.Success("数据提交成功", true)));
                }
                else
                {
                    return(Ok(response.Error(ResponseCode.ERROR, "数据提交失败")));
                }
            }
        }
Ejemplo n.º 2
0
        public ActionResult SaveDictType()
        {
            DictTypeModel dictType = new DictTypeModel();

            dictType = ObjectUtil.Eval(dictType, Request.Params, "", "");
            JsResultObject result = BaseZdBiz.SaveOrUpdate(dictType, "字典类型");

            this.reflashDictCache();
            return(JsonText(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        private void HandleRequestData(DictTypeModel item, List <SysDictType> list)
        {
            if (item == null)
            {
                return;
            }
            var mapConfig = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <string, int?>().ConvertUsing(new NullableIntUtcTimeTypeConverter());
                cfg.CreateMap <string, DateTime?>().ConvertUsing(new NullableUtcTimeTypeConverter());
                cfg.CreateMap <DictTypeModel, SysDictType>();
            });
            //mapConfig.AssertConfigurationIsValid();
            var result = item.MapTo <DictTypeModel, SysDictType>(mapConfig);

            list.Add(result);
        }