Пример #1
0
 public BaseResponse <bool> Create(CommonResourceCreateModel model)
 {
     try
     {
         if (model != null && !string.IsNullOrEmpty(model.ResourceKey) && !string.IsNullOrEmpty(model.ResourceValue))
         {
             var entity = new CommonResources();
             entity.InjectFrom(model);
             _commonContext.CommonResources.Add(entity);
             _commonContext.SaveChanges();
             return(BaseResponse <bool> .Success(true));
         }
         return(BaseResponse <bool> .BadRequest());
     }
     catch (Exception ex)
     {
         return(BaseResponse <bool> .InternalServerError(ex));
     }
 }
Пример #2
0
 public BaseResponse <bool> Create(CommonValueCreateModel model)
 {
     try
     {
         var entity = _mapper.Map <CommonValueCreateModel, CommonValues>(model);
         entity.UniqueId = UniqueIDHelper.GenarateRandomString(12);
         _commonContext.CommonValues.Add(entity);
         _commonContext.SaveChanges();
         return(BaseResponse <bool> .Success(true));
     }
     catch (Exception ex)
     {
         return(BaseResponse <bool> .InternalServerError(ex));
     }
 }