Exemplo n.º 1
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public JsonResult Add(DataDictionary entity)
 {
     ModelState.Remove("ID");
     ModelState.Remove("CreatedTime");
     ModelState.Remove("UpdatedTime");
     ModelState.Remove("IsDelete");
     if (ModelState.IsValid)
     {
         if (IDataDictionaryService.IsExits(x => x.Key == entity.Key))
         {
             return(JResult(Core.Code.ErrorCode.system_key_already_exist, ""));
         }
         entity.CreatedTime = entity.UpdatedTime = DateTime.Now;
         var result = IDataDictionaryService.Add(entity);
         if (result > 0)
         {
             CacheHelper.Clear();
         }
         return(JResult(result));
     }
     else
     {
         return(ParamsErrorJResult(ModelState));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public JsonResult Add(DataDictionary entity)
 {
     ModelState.Remove("ID");
     ModelState.Remove("CreatedTime");
     ModelState.Remove("UpdatedTime");
     ModelState.Remove("IsDelete");
     if (ModelState.IsValid)
     {
         if (IDataDictionaryService.IsExits(x => x.Value == entity.Value))
         {
             return(JResult(Core.Code.ErrorCode.system_name_already_exist, ""));
         }
         entity.CreatedTime = entity.UpdatedTime = DateTime.Now;
         if (entity.Key.IsNullOrEmpty())
         {
             entity.ID = entity.Key = Guid.NewGuid().ToString("N");
         }
         var result = IDataDictionaryService.Add(entity);
         if (result > 0)
         {
             CacheHelper.Clear();
         }
         return(JResult(result));
     }
     else
     {
         return(ParamsErrorJResult(ModelState));
     }
 }