Beispiel #1
0
        private async Task <BlockchainSettingEntity> GetBlockchainSettingEntity(string type)
        {
            BlockchainSettingEntity entity = await _table.GetDataAsync(BlockchainSettingEntity.GetPartitionKey(type),
                                                                       BlockchainSettingEntity.GetRowKey(type));

            return(entity);
        }
Beispiel #2
0
        /// <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);
            }
        }
Beispiel #3
0
        /// <inheritdoc />>
        public async Task RemoveAsync(string type)
        {
            string partitionKey = BlockchainSettingEntity.GetPartitionKey(type);
            string rowKey       = BlockchainSettingEntity.GetRowKey(type);
            BlockchainSettingEntity existing = await GetBlockchainSettingEntity(type);

            if (existing == null)
            {
                throw new DoesNotExistException($"Settings with type {type} does not exist");
            }

            await _table.DeleteIfExistAsync(partitionKey, rowKey);
        }