示例#1
0
        /// <summary>
        /// Updates the specified user model.
        /// </summary>
        /// <param name="dynamicModel">The user model.</param>
        /// <returns>IActionResult.</returns>
        public IActionResult Update(dynamic dynamicModel)
        {
            var response = new ResponseResult <DictDataModel>();

            if (dynamicModel == null || dynamicModel.id < 1)
            {
                return(Ok(response.Error(ResponseCode.INVALID_PARAMS, "该数据不存在")));
            }
            int         id    = dynamicModel.id;
            SysDictData model = null;

            using (_dbContext)
            {
                (from dict in _dbContext.SysDictData
                 join dictType in _dbContext.SysDictType on dict.DictTypeId equals dictType.Id
                 where dict.Id == id
                 select new SysDictData(dict, dictType.DictType, dictType.DictValueType)).FirstOrDefault();
            }
            if (model == null)
            {
                return(Ok(response.Error(ResponseCode.ERROR_CODE__DB__NO_ROW, "该数据不存在")));
            }
            var mapConfig = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <int?, string>().ConvertUsing(new UtcStringTimeTypeConverter());
                cfg.CreateMap <DateTime?, string>().ConvertUsing(new UtcDateTimeTypeConverter());
                cfg.CreateMap <SysDictData, DictDataModel>();
            });
            var data = model.MapTo <SysDictData, DictDataModel>(mapConfig);

            return(Ok(response.Success("数据获取成功", data)));
        }
        public AjaxReponseBase edit([FromBody] SysDictData dict)
        {
            string username = SecurityUtils.getUsername(tokenService, httpContextAccessor.HttpContext.Request);

            dict.UpdateBy = (username);
            return(toAjax(dictDataService.updateDictData(dict)));
        }
        public TableDataInfo <SysDictData> list(SysDictData dictData)
        {
            startPage(httpContextAccessor);
            long total = 1;
            List <SysDictData> list = dictDataService.selectDictDataList(dictData);

            return(getDataTable(list, total));
        }
示例#4
0
 public string Upd(SysDictData Table_entity)
 {
     try
     {
         _app.Upd(Table_entity);
     }
     catch (Exception ex)
     {
         Result.Status  = false;
         Result.Message = ex.Message;
     }
     return(JsonHelper.Instance.Serialize(Result));
 }
示例#5
0
        public string FindSysDictData(SysDictData entity)
        {
            TableData res = new TableData();

            if (entity.DictType != null)
            {
                var data = _app.Find(n => n.DictType == entity.DictType).OrderBy(x => x.DictSort);
                res.data  = data;
                res.count = data.Count();

                return(JsonHelper.Instance.Serialize(res));;
            }
            else
            {
                return("");
            }
        }
示例#6
0
        public string GetTemplate()
        {
            var result = new TableData();
            List <SysDictData> listSysDictData = new List <SysDictData>();
            SysDictData        entity          = _app.FindSingle(u => u.Id > 0);

            if (entity != null)
            {
                listSysDictData.Add(entity);
            }
            else
            {
                listSysDictData.Add(new SysDictData());
            }

            result.data  = listSysDictData;
            result.count = listSysDictData.Count;

            return(JsonHelper.Instance.Serialize(result));
        }
        public AjaxReponseBase export(SysDictData dictData)
        {
            string rootpath = hostingEnvironment.WebRootPath + @"\ExcelFiles";

            if (!Directory.Exists(rootpath))
            {
                Directory.CreateDirectory(rootpath);
            }
            string             fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + dictData.DictType + ".xlsx";
            List <SysDictData> list     = dictDataService.selectDictDataList(dictData);
            bool exportOK = ExcelUtil.ExportExcelToFile <SysDictData>(list, "参数数据", null, rootpath, fileName);

            if (exportOK)
            {
                return(AjaxReponseBase.Success(fileName));
            }
            else
            {
                return(AjaxReponseBase.Error("导出失败!"));
            }
        }
示例#8
0
 public string Load(PageReq pageRequest, SysDictData entity)
 {
     return(JsonHelper.Instance.Serialize(_app.Load(pageRequest, entity)));
 }
示例#9
0
 public string Export(SysDictData entity)
 {
     return(JsonHelper.Instance.Serialize(_app.ExportData(entity)));
 }
示例#10
0
 public int updateDictData(SysDictData dict)
 {
     throw new NotImplementedException();
 }
示例#11
0
 public List <SysDictData> selectDictDataList(SysDictData dictData)
 {
     throw new NotImplementedException();
 }
示例#12
0
 public int insertDictData(SysDictData dict)
 {
     throw new NotImplementedException();
 }