/// <inheritdoc /> public async Task UpdateAsync(BlockchainSetting settings) { BlockchainSettingEntity entity = BlockchainSettingEntity.FromDomain(settings); string partitionKey = BlockchainSettingEntity.GetPartitionKey(settings.Type); string rowKey = BlockchainSettingEntity.GetRowKey(settings.Type); string errorMessage = null; bool isUpdated = await _table.InsertOrModifyAsync(partitionKey, rowKey, () => entity, model => { if (model.ETag != entity.ETag) { errorMessage = $"Entity with type {model.Type} has eTag == {model.ETag}, eTag in update request is {entity.ETag}"; return(false); } model.Type = entity.Type; model.ApiUrl = entity.ApiUrl; model.HotWalletAddress = entity.HotWalletAddress; model.SignServiceUrl = entity.SignServiceUrl; model.ETag = entity.ETag; model.PartitionKey = entity.PartitionKey; model.RowKey = entity.RowKey; return(true); }); if (!isUpdated) { throw new AlreadyUpdatedException(errorMessage); } }
/// <inheritdoc /> public async Task CreateAsync(BlockchainSetting settings) { var existing = await GetBlockchainSettingEntity(settings.Type); if (existing != null) { throw new AlreadyExistsException($"Setting with type {settings.Type} is already exists"); } BlockchainSettingEntity entity = BlockchainSettingEntity.FromDomain(settings); await _table.InsertAsync(entity); }