public async Task <WalletDto> TryGetAsync(string blockchainType, string assetId, Guid clientId) { var partitionKey = WalletEntity.GetPartitionKey(blockchainType, assetId, clientId); var rowKey = WalletEntity.GetRowKey(clientId); var entity = await _walletsTable.GetDataAsync(partitionKey, rowKey); return(entity != null ? ConvertEntityToDto(entity) : null); }
public async Task DeleteIfExistsAsync(string blockchainType, string assetId, Guid clientId) { var partitionKey = WalletEntity.GetPartitionKey(blockchainType, assetId, clientId); var rowKey = WalletEntity.GetRowKey(clientId); var wallet = await _walletsTable.GetDataAsync(partitionKey, rowKey); if (wallet != null) { var(indexPartitionKey, indexRowKey) = GetAddressIndexKeys(wallet); var(clientIndexPartitionKey, clientIndexRowKey) = GetClientIndexKeys(wallet); await _walletsTable.DeleteIfExistAsync(wallet.PartitionKey, wallet.RowKey); await _addressIndexTable.DeleteIfExistAsync(indexPartitionKey, indexRowKey); await _clientIndexTable.DeleteIfExistAsync(clientIndexPartitionKey, clientIndexRowKey); } }
public async Task AddAsync(string blockchainType, string assetId, Guid clientId, string address) { var partitionKey = WalletEntity.GetPartitionKey(blockchainType, assetId, clientId); var rowKey = WalletEntity.GetRowKey(clientId); // Address index var(indexPartitionKey, indexRowKey) = GetAddressIndexKeys(blockchainType, address); var(clientIndexPartitionKey, clientIndexRowKey) = GetClientIndexKeys(blockchainType, assetId, clientId); await _addressIndexTable.InsertOrReplaceAsync(new AzureIndex( indexPartitionKey, indexRowKey, partitionKey, rowKey )); await _clientIndexTable.InsertOrReplaceAsync(new AzureIndex( clientIndexPartitionKey, clientIndexRowKey, partitionKey, rowKey )); // Wallet entity await _walletsTable.InsertOrReplaceAsync(new WalletEntity { PartitionKey = partitionKey, RowKey = rowKey, Address = address, AssetId = assetId, ClientId = clientId, IntegrationLayerId = blockchainType }); }