public async Task <IBcnWalletUsage> CreateAsync(IBcnWalletUsage usage) { var entity = BcnWalletUsageEntity.ByWalletAddress.Create(usage); await _tableStorage.InsertAsync(entity); return(Mapper.Map <BcnWalletUsage>(entity)); }
public async Task <bool> TryLockAsync(IBcnWalletUsage usage) { string partitionKey = BcnWalletUsageEntity.ByWalletAddress.GeneratePartitionKey(usage.WalletAddress); string rowKey = BcnWalletUsageEntity.ByWalletAddress.GenerateRowKey(usage.Blockchain); return(await _tableStorage.InsertOrModifyAsync(partitionKey, rowKey, () => BcnWalletUsageEntity.ByWalletAddress.Create(usage), existing => { if (!string.IsNullOrEmpty(existing.OccupiedBy)) { return false; } existing.OccupiedBy = usage.OccupiedBy; existing.Since = usage.Since; return true; })); }
public async Task <string> ResolveOccupierAsync(string walletAddress, BlockchainType blockchain) { IBcnWalletUsage usage = await _walletUsageRepository.GetAsync(walletAddress, blockchain); return(usage?.OccupiedBy); }