public void Save(List <ModuleOptionStorageModel> descriptors) { if (descriptors == null || !descriptors.Any()) { return; } using var uow = _dbContext.NewUnitOfWork(); foreach (var descriptor in descriptors) { var newEntity = new ConfigEntity { Type = ConfigType.Module, Key = descriptor.Key, Value = descriptor.Value, Remarks = descriptor.Remarks }; var entity = _repository.GetByKey(descriptor.Key, ConfigType.Module).Result; if (entity == null) { _repository.AddAsync(newEntity, uow).GetAwaiter().GetResult(); } else { newEntity.Id = entity.Id; _repository.UpdateAsync(newEntity, uow).GetAwaiter().GetResult(); } } }
public async Task Save(List <ModuleOptionDescriptor> descriptors) { if (descriptors == null || !descriptors.Any()) { return; } using var uow = _dbContext.NewUnitOfWork(); foreach (var descriptor in descriptors) { var newEntity = new ConfigEntity { Type = ConfigType.Module, Key = descriptor.Key, Value = descriptor.Value, Remarks = descriptor.Remarks }; var entity = await _repository.GetByKey(descriptor.Key, ConfigType.Module); if (entity == null) { await _repository.AddAsync(newEntity, uow); } else { newEntity.Id = entity.Id; await _repository.UpdateAsync(newEntity, uow); } } }
public async Task Add(ConfigDescriptor descriptor) { if (descriptor == null) { return; } await _repository.AddAsync(new ConfigEntity { Key = descriptor.Key, Value = descriptor.Value, Remarks = descriptor.Remarks }); }
public async Task UpdateAsync(NdmConfig config) { if (!_config.StoreConfigInDatabase) { return; } var existingConfig = await _repository.GetAsync(config.Id); if (existingConfig is null) { await _repository.AddAsync(config); return; } await _repository.UpdateAsync(config); }
public async Task <IResultModel> Add(ConfigAddModel model) { if (await _repository.Exists(model.Key)) { return(ResultModel.HasExists); } var entity = new ConfigEntity { Key = model.Key, Value = model.Value, Remarks = model.Remarks }; var result = await _repository.AddAsync(entity); return(ResultModel.Result(result)); }
public async Task <bool> SaveJson(ConfigType type, string code, string json) { if (code.IsNull()) { throw new NullReferenceException("编码不能为空"); } var entity = await _repository.Get(type, code) ?? new ConfigEntity(); entity.Type = type; entity.Code = code; entity.Value = json; if (entity.Id > 0) { return(await _repository.UpdateAsync(entity)); } return(await _repository.AddAsync(entity)); }
public async Task <Config> Add(Config input) { return(await _configRepository.AddAsync(input)); }