Example #1
0
        public async Task <IBcnWalletUsage> CreateAsync(IBcnWalletUsage usage)
        {
            var entity = BcnWalletUsageEntity.ByWalletAddress.Create(usage);

            await _tableStorage.InsertAsync(entity);

            return(Mapper.Map <BcnWalletUsage>(entity));
        }
Example #2
0
        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;
            }));
        }
Example #3
0
        public async Task <string> ResolveOccupierAsync(string walletAddress, BlockchainType blockchain)
        {
            IBcnWalletUsage usage = await _walletUsageRepository.GetAsync(walletAddress, blockchain);

            return(usage?.OccupiedBy);
        }