public async Task SaveAsync(IVirtualWallet wallet) { string partitionKey = VirtualWalletEntity.ByMerchantId.GeneratePartitionKey(wallet.MerchantId); string rowKey = VirtualWalletEntity.ByMerchantId.GenerateRowKey(wallet.Id); VirtualWalletEntity exItem = wallet.Id != null ? await _tableStorage.GetDataAsync(partitionKey, rowKey) : null; if (exItem != null) { await _tableStorage.MergeAsync(partitionKey, rowKey, entity => { entity.BlockchainWallets = wallet.BlockchainWallets; return(entity); }); return; } VirtualWalletEntity newEntity = VirtualWalletEntity.ByMerchantId.Create(wallet); await _tableStorage.InsertAsync(newEntity); }
public async Task <IVirtualWallet> GetAsync(string merchantId, string walletId) { VirtualWalletEntity entity = await _tableStorage.GetDataAsync( VirtualWalletEntity.ByMerchantId.GeneratePartitionKey(merchantId), VirtualWalletEntity.ByMerchantId.GenerateRowKey(walletId)); return(Mapper.Map <VirtualWallet>(entity)); }
public async Task <IVirtualWallet> FindAsync(string walletId) { AzureIndex index = await _walletIdIndexStorage.GetDataAsync( VirtualWalletEntity.IndexByWalletId.GeneratePartitionKey(walletId), VirtualWalletEntity.IndexByWalletId.GenerateRowKey()); if (index == null) { return(null); } VirtualWalletEntity entity = await _tableStorage.GetDataAsync(index); return(Mapper.Map <VirtualWallet>(entity)); }
public async Task <IVirtualWallet> CreateAsync(IVirtualWallet wallet) { VirtualWalletEntity entity = VirtualWalletEntity.ByMerchantId.Create(wallet); await _tableStorage.InsertAsync(entity); AzureIndex indexByWalletId = VirtualWalletEntity.IndexByWalletId.Create(entity); await _walletIdIndexStorage.InsertAsync(indexByWalletId); AzureIndex indexByDueDate = VirtualWalletEntity.IndexByDueDate.Create(entity); await _dueDateIndexStorage.InsertAsync(indexByDueDate); return(Mapper.Map <VirtualWallet>(entity)); }