public async Task <bool> TryCreateAsync(IMarketOrder marketOrder)
        {
            var byOrderEntity  = MarketOrderEntity.ByOrderId.Create(marketOrder);
            var byClientEntity = MarketOrderEntity.ByClientId.Create(marketOrder);

            return(await _tableStorage.TryInsertAsync(byOrderEntity) && await _tableStorage.TryInsertAsync(byClientEntity));
        }
Example #2
0
        public async Task SaveAsync(IBcnCredentialsRecord credsRecord)
        {
            var byClientEntity       = FirstGenerationBlockchainWalletEntity.FromBcnClientCredentials.ByClientId.Create(credsRecord);
            var byAssetAddressEntity = FirstGenerationBlockchainWalletEntity.FromBcnClientCredentials.ByAssetAddress.Create(credsRecord);

            await _bcnClientCredentialsWalletTable.TryInsertAsync(byClientEntity);

            await _bcnClientCredentialsWalletTable.TryInsertAsync(byAssetAddressEntity);
        }
        public Task <bool> TryAddToIncomingHistoryObservationList(
            string address)
        {
            var(partitionKey, rowKey) = GetKeys(address, true);

            return(_addresses.TryInsertAsync(new TransactionHistoryObservationAddressEntity
            {
                PartitionKey = partitionKey,
                RowKey = rowKey
            }));
        }
Example #4
0
 public async Task InsertAsync(IObservableWallet wallet)
 {
     if (!await _storage.TryInsertAsync(ObservableWalletEntity.Create(wallet)))
     {
         throw new BusinessException($"Wallet {wallet.Address} already exist", ErrorCode.EntityAlreadyExist);
     }
 }
Example #5
0
        public async Task AddAsync(IExpiryEntry entry)
        {
            var alreadyExisted = !await
                                 _tableStorage.TryInsertAsync(
                new ExpiryEntryEntity
            {
                PartitionKey   = ExpiryEntryEntity.ByClient.GeneratePartitionKey(entry.ClientId),
                RowKey         = ExpiryEntryEntity.ByClient.GenerateRowKey(entry.RequestId),
                ClientId       = entry.ClientId,
                RequestId      = entry.RequestId,
                ExpiryDateTime = entry.ExpiryDateTime
            });

            if (!alreadyExisted)
            {
                await _tableStorage.InsertAsync(
                    new ExpiryEntryEntity
                {
                    PartitionKey   = ExpiryEntryEntity.ByDateTime.GeneratePartitionKey(),
                    RowKey         = ExpiryEntryEntity.ByDateTime.GenerateRowKey(entry.ExpiryDateTime, entry.RequestId),
                    ClientId       = entry.ClientId,
                    RequestId      = entry.RequestId,
                    ExpiryDateTime = entry.ExpiryDateTime
                });
            }
        }
        public virtual async Task <bool> TryInsertAsync(TD obj)
        {
            var entity = ConvertService.Convert <TD, TE>(obj, DefaultAzureMappingOpts);

            entity.SetKeys();
            return(await TableStorage.TryInsertAsync(entity));
        }
        public async Task <bool> TryCreateAsync(string transactionId, string commandType,
                                                string requestData, string contextData, string response, string blockchainHash = null)
        {
            var newEntity = BitCoinTransactionEntity.ByTransactionId.CreateNew(transactionId, commandType, requestData, contextData, response, blockchainHash);

            return(await _tableStorage.TryInsertAsync(newEntity));
        }
        public async Task <string> AddAsync(SmsMessage message)
        {
            var entity = SmsMessageEntity.Create(message);
            await _tableStorage.TryInsertAsync(entity);

            var indexEntity = AzureIndex.Create(IdIndex, entity.Id, entity);
            await _index.InsertAsync(indexEntity);

            return(entity.Id);
        }
Example #9
0
        public async Task <bool> TryAddAsync(string address)
        {
            var entity = new ObservableBalanceEntity
            {
                PartitionKey = GetPartitionKey(address),
                RowKey       = GetRowKey(address),

                Address     = address,
                Amount      = 0,
                BlockNumber = 0
            };

            return(await _table.TryInsertAsync(entity));
        }
        public async Task AddAsync(INetwork network)
        {
            var existing = (await _tableStorage.GetDataAsync(x => x.Name == network.Name)).FirstOrDefault();

            if (existing != null)
            {
                await UpdateIp(existing.Id, network.Ip);
            }
            else
            {
                var entity = NetworkEntity.Create(network);
                await _tableStorage.TryInsertAsync(entity);
            }
        }
Example #11
0
        public Task <bool> AddIfNotExistsAsync(
            string address,
            string reason)
        {
            var(partitionKey, rowKey) = GetKeys(address);

            return(_blacklistedAddresses.TryInsertAsync
                   (
                       new BlacklistedAddressEntity
            {
                Reason = reason,

                PartitionKey = partitionKey,
                RowKey = rowKey
            }
                   ));
        }
        public Task <bool> AddIfNotExistsAsync(
            string address,
            BigInteger maxGasAmount)
        {
            var(partitionKey, rowKey) = GetKeys(address);

            return(_whitelistedAddresses.TryInsertAsync
                   (
                       new WhitelistedAddressEntity
            {
                MaxGasAmount = maxGasAmount,

                PartitionKey = partitionKey,
                RowKey = rowKey
            }
                   ));
        }
        public async Task AddAsync(SmsProvider provider, string countryCode, SmsDeliveryStatus status)
        {
            var entity = await _tableStorage.GetDataAsync(SmsProviderInfoEntity.GeneratePartitionKey(provider),
                                                          SmsProviderInfoEntity.GenerateRowKey(countryCode));

            if (entity == null)
            {
                entity = SmsProviderInfoEntity.Create(provider, countryCode, status);
                await _tableStorage.TryInsertAsync(entity);
            }
            else
            {
                await _tableStorage.MergeAsync(SmsProviderInfoEntity.GeneratePartitionKey(provider), SmsProviderInfoEntity.GenerateRowKey(countryCode),
                                               infoEntity =>
                {
                    switch (status)
                    {
                    case SmsDeliveryStatus.Delivered:
                        infoEntity.DeliveredCount++;
                        break;

                    case SmsDeliveryStatus.Failed:
                        infoEntity.DeliveryFailedCount++;
                        break;

                    case SmsDeliveryStatus.Unknown:
                        infoEntity.UnknownCount++;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(status), status, null);
                    }

                    return(infoEntity);
                });
            }
        }
Example #14
0
 public Task <bool> TryInsert(IOperationMeta meta)
 {
     return(_storage.TryInsertAsync(OperationMetaEntity.ByOperationId.Create(meta)));
 }
Example #15
0
        public Task <bool> TryInsertAsync <T>(string id, ICashoutRequest request, PaymentSystem paymentSystem, T paymentFields, CashoutRequestTradeSystem tradeSystem)
        {
            var entity = CashoutAttemptEntity.PendingRecords.Create(id, request, paymentSystem, paymentFields, tradeSystem);

            return(_tableStorage.TryInsertAsync(entity));
        }
Example #16
0
 public Task InsertIfNotExist(IOperationEvent operationEvent)
 {
     return(_storage.TryInsertAsync(OperationEventTableEntity.Create(operationEvent)));
 }
Example #17
0
 public Task AddAsync(string clientId, double rank, string changer, string comment)
 {
     return(_tableStorage.TryInsertAsync(QuestionRankEntity.Create(clientId, rank, changer, comment)));
 }