Exemplo n.º 1
0
        public async Task ReleaseAsync(DepositWalletKey key, Guid operationId)
        {
            var partitionKey = DepositWalletLockEntity.GetPartitionKey(key);
            var rowKey       = DepositWalletLockEntity.GetRowKey(key);

            await _storage.DeleteIfExistAsync(partitionKey, rowKey, e => e.OperationId == operationId);
        }
Exemplo n.º 2
0
        public async Task <DepositWalletLock> LockAsync(
            DepositWalletKey key,
            decimal balance,
            long block,
            Func <Guid> operationIdFactory)
        {
            var partitionKey = DepositWalletLockEntity.GetPartitionKey(key);
            var rowKey       = DepositWalletLockEntity.GetRowKey(key);

            var entity = await _storage.GetOrInsertAsync
                         (
                partitionKey,
                rowKey,
                // ReSharper disable once ImplicitlyCapturedClosure
                () => DepositWalletLockEntity.Create
                (
                    key,
                    balance,
                    block,
                    operationIdFactory()
                )
                         );

            return(DepositWalletLock.Create(key, entity.OperationId, entity.Balance, entity.Block));
        }