예제 #1
0
        /// <summary>
        /// 验证字典
        /// </summary>
        /// <param name="dictionary"></param>
        /// <returns></returns>
        private ResponseBase ValidationDictionary(SysDictionaryDto dictionary)
        {
            var response = new ResponseBase();

            response.IsSuccess = false;
            if (string.IsNullOrEmpty(dictionary.DictionaryCode))
            {
                response.OperationDesc = "字典编码不能为空";
            }

            if (string.IsNullOrEmpty(dictionary.DictionaryName))
            {
                response.OperationDesc = "字典名称不能为空";
            }

            if (SystemRepo.IsExisDictionary(dictionary))
            {
                response.OperationDesc = "字典编码已存在";
            }
            else
            {
                response.IsSuccess = true;
            }

            return(response);
        }
예제 #2
0
        /// <summary>
        /// 编辑数据字典
        /// </summary>
        /// <param name="model">数据字典信息</param>
        /// <returns>是否成功</returns>
        public ResponseBase EditSysDictionary(SysDictionaryDto model)
        {
            var response = ValidationDictionary(model);

            if (!response.IsSuccess)
            {
                return(response);
            }

            try
            {
                response.IsSuccess = SystemRepo.EditSysDictionary(model) > 0;
                CacheManager.Remove(CacheKeyConstantVariable.Dictionary);
            }
            catch (Exception ex)
            {
                WriteLogError(ex.ToString());
                response.IsSuccess     = false;
                response.OperationDesc = ex.ToString();
            }

            return(response);
        }
예제 #3
0
        /// <summary>
        /// 添加数据字典
        /// </summary>
        /// <param name="model">数据字典信息</param>
        /// <returns>是否成功</returns>
        public ResponseBase CreateSysDictionary(SysDictionaryDto model)
        {
            var response = ValidationDictionary(model);

            if (!response.IsSuccess)
            {
                return(response);
            }

            try
            {
                response.IsSuccess = SystemRepo.CreateSysDictionary(model) > 0;
                CacheManager.Remove(CacheKeyConstantVariable.Dictionary);
            }
            catch (Exception ex)
            {
                WriteLogError(ex.ToString());
                Logger.Log(Core.Infrastructure.Logging.LogLevel.Error, ex, string.Empty);
                response.IsSuccess     = false;
                response.OperationDesc = ex.ToString();
            }

            return(response);
        }