Exemple #1
0
 public Task UpdateAsync(Settlement settlement)
 {
     return(_storage.MergeAsync(GetPartitionKey(settlement.Id), GetRowKey(settlement.Id), entity =>
     {
         Mapper.Map(settlement, entity);
         return entity;
     }));
 }
Exemple #2
0
 public async Task SetStatusAsync(string merchantId, string invoiceId, InvoiceStatus status)
 {
     await _storage.MergeAsync(GetPartitionKey(merchantId), GetRowKey(invoiceId), entity =>
     {
         entity.Status = status.ToString();
         return(entity);
     });
 }
Exemple #3
0
        public async Task <Employee> MarkDeletedAsync(string merchantId, string employeeId)
        {
            var entity = await _storage.MergeAsync(GetPartitionKey(merchantId), GetRowKey(employeeId), mergingEntity =>
            {
                mergingEntity.IsDeleted = true;
                return(mergingEntity);
            });

            return(Mapper.Map <Employee>(entity));
        }
Exemple #4
0
        public async Task <IBitcoinTransaction> SaveResponseAndHashAsync(string transactionId, string resp, string hash, DateTime?dateTime = null)
        {
            var partitionKey = BitCoinTransactionEntity.ByTransactionId.GeneratePartitionKey();
            var rowKey       = BitCoinTransactionEntity.ByTransactionId.GenerateRowKey(transactionId);

            return(await _tableStorage.MergeAsync(partitionKey, rowKey, entity =>
            {
                entity.UpdateResponse(resp, dateTime);
                entity.BlockchainHash = hash;
                return entity;
            }));
        }
        public async Task AddChildTransfer(string transferId, IOffchainTransfer child)
        {
            await _storage.MergeAsync(OffchainTransferEntity.ByCommon.GeneratePartitionKey(), transferId,
                                      entity =>
            {
                var data = entity.GetAdditionalData();
                data.ChildTransfers.Add(child.Id);
                entity.SetAdditionalData(data);

                entity.Amount += child.Amount;

                return(entity);
            });
        }
Exemple #6
0
        public static async Task <T> MergeAsync <T>(this INoSQLTableStorage <AzureMultiIndex> indexTable, string partitionKey, string rowKey, INoSQLTableStorage <T> dataTable, Func <T, T> replaceCallback) where T : class, ITableEntity, new()
        {
            var indexEntity = await indexTable.GetDataAsync(partitionKey, rowKey);

            if (indexEntity == null)
            {
                return(null);
            }

            var indices = indexEntity.GetData();

            if (indices.Length == 0)
            {
                return(null);
            }


            var tasks = new List <Task <T> >();

            foreach (var index in indices)
            {
                var task = dataTable.MergeAsync(index.Pk, index.Rk, replaceCallback);
                tasks.Add(task);
            }

            await Task.WhenAll(tasks);


            return(tasks[0].Result);
        }
Exemple #7
0
        public async Task <Core.Domain.ResetPasswordAccessToken> UpdateAsync(Core.Domain.ResetPasswordAccessToken src)
        {
            AzureIndex index = await _indexByPublicIdStorage.GetDataAsync(
                ResetPasswordAccessTokenEntity.IndexByPublicId.GeneratePartitionKey(src.PublicId),
                ResetPasswordAccessTokenEntity.IndexByPublicId.GenerateRowKey());

            if (index == null)
            {
                throw new KeyNotFoundException();
            }

            ResetPasswordAccessTokenEntity updatedEntity = await _storage.MergeAsync(
                ResetPasswordAccessTokenEntity.ByEmployeeId.GeneratePartitionKey(index.PrimaryPartitionKey),
                ResetPasswordAccessTokenEntity.ByEmployeeId.GenerateRowKey(index.PrimaryRowKey),
                entity =>
            {
                entity.Redeemed = src.Redeemed;

                return(entity);
            });

            if (updatedEntity == null)
            {
                throw new KeyNotFoundException();
            }

            return(Mapper.Map <Core.Domain.ResetPasswordAccessToken>(updatedEntity));
        }
Exemple #8
0
        public async Task <IAssetGeneralSettings> SetAsync(IAssetGeneralSettings availability)
        {
            string partitionKey = AssetGeneralSettingsEntity.ByAsset.GeneratePartitionKey(availability.AssetId);
            string rowKey       = AssetGeneralSettingsEntity.ByAsset.GenerateRowKey(availability.AssetId);

            AssetGeneralSettingsEntity exItem = await _tableStorage.GetDataAsync(partitionKey, rowKey);

            if (exItem != null)
            {
                AssetGeneralSettingsEntity merged = await _tableStorage.MergeAsync(partitionKey, rowKey, item =>
                {
                    item.PaymentAvailable    = availability.PaymentAvailable;
                    item.SettlementAvailable = availability.SettlementAvailable;
                    item.AutoSettle          = availability.AutoSettle;
                    item.Network             = availability.Network;

                    return(item);
                });

                return(Mapper.Map <AssetGeneralSettings>(merged));
            }

            var newItem = AssetGeneralSettingsEntity.ByAsset.Create(availability);

            await _tableStorage.InsertAsync(newItem);

            return(Mapper.Map <AssetGeneralSettings>(newItem));
        }
        public async Task UpdateAsync(IMerchantConfigurationLine src)
        {
            string pKey = MerchantConfigurationLineEntity.ByMerchant.GeneratePartitionKey(src.MerchantId);
            string rKey = MerchantConfigurationLineEntity.ByMerchant.GenerateRowKey(src.RuleId);

            MerchantConfigurationLineEntity updatedEntity = await _storage.MergeAsync(pKey, rKey,
                                                                                      entity =>
            {
                if (src.RuleInput != null)
                {
                    entity.RuleInput = src.RuleInput;
                }
                if (src.Enabled.HasValue)
                {
                    entity.Enabled = src.Enabled.Value;
                }

                return(entity);
            });

            if (updatedEntity == null)
            {
                throw new EntityNotFoundException(pKey, rKey);
            }
        }
Exemple #10
0
        public async Task <OperationEntity> UpdateAsync(Guid operationId, DateTime?sendTime = null, DateTime?completionTime = null,
                                                        DateTime?blockTime = null, DateTime?failTime             = null, DateTime?deleteTime    = null, string transactionHash = null, long?blockNumber = null,
                                                        string error       = null, BlockchainErrorCode?errorCode = null, string broadcastResult = null)
        {
            if (!string.IsNullOrEmpty(transactionHash))
            {
                await _operationIndexStorage.InsertOrReplaceAsync(new OperationIndexEntity(transactionHash, operationId));
            }

            return(await _operationStorage.MergeAsync(
                       OperationEntity.Partition(operationId),
                       OperationEntity.Row(),
                       op =>
            {
                op.SendTime = sendTime ?? op.SendTime;
                op.CompletionTime = completionTime ?? op.CompletionTime;
                op.BlockTime = blockTime ?? op.BlockTime;
                op.FailTime = failTime ?? op.FailTime;
                op.DeleteTime = deleteTime ?? op.DeleteTime;
                op.TransactionHash = transactionHash ?? op.TransactionHash;
                op.BlockNumber = blockNumber ?? op.BlockNumber;
                op.Error = error ?? op.Error;
                op.ErrorCode = errorCode ?? op.ErrorCode;
                op.BroadcastResult = broadcastResult ?? op.BroadcastResult;
                return op;
            }
                       ));
        }
Exemple #11
0
        public async Task <IOffchainRequest> CreateRequestAndLock(string transferId, string clientId, string assetId,
                                                                  RequestType type, OffchainTransferType transferType, DateTime?lockDate)
        {
            var existingRequest = (await GetRequestsForClient(clientId)).FirstOrDefault(x => x.AssetId == assetId &&
                                                                                        x.TransferType == transferType &&
                                                                                        x.StartProcessing == null);

            if (existingRequest == null)
            {
                return(await CreateRequest(transferId, clientId, assetId, type, transferType, lockDate));
            }

            var replaced = await _table.MergeAsync(OffchainRequestEntity.ByRecord.Partition, existingRequest.RequestId, entity =>
            {
                if (entity.StartProcessing != null)
                {
                    return(null);
                }

                entity.ServerLock = lockDate;
                return(entity);
            });

            if (replaced == null)
            {
                return(await CreateRequest(transferId, clientId, assetId, type, transferType, lockDate));
            }

            return(replaced);
        }
        public async Task UpdateAsync(
            Transaction transaction)
        {
            TransactionEntity MergeAction(TransactionEntity entity)
            {
                entity.Amount        = transaction.Amount;
                entity.BlockNumber   = transaction.BlockNumber;
                entity.BroadcastedOn = transaction.BroadcastedOn;
                entity.BuiltOn       = transaction.BuiltOn;
                entity.CompletedOn   = transaction.CompletedOn;
                entity.Data          = transaction.Data;
                entity.DeletedOn     = transaction.DeletedOn;
                entity.Error         = transaction.Error;
                entity.From          = transaction.From;
                entity.GasAmount     = transaction.GasAmount;
                entity.GasPrice      = transaction.GasPrice;
                entity.Hash          = transaction.Hash;
                entity.IncludeFee    = transaction.IncludeFee;
                entity.SignedData    = transaction.SignedData;
                entity.State         = transaction.State;
                entity.To            = transaction.To;
                entity.TransactionId = transaction.TransactionId;

                return(entity);
            }

            var(partitionKey, rowKey) = GetTransactionKeys(transaction.TransactionId);

            await _transactions.MergeAsync
            (
                partitionKey : partitionKey,
                rowKey : rowKey,
                mergeAction : MergeAction
            );
        }
Exemple #13
0
        public async Task UpdateAsync(IMerchantWallet src)
        {
            MerchantWalletEntity updatedEntity = await _tableStorage.MergeAsync(
                MerchantWalletEntity.ByMerchant.GeneratePartitionKey(src.MerchantId),
                MerchantWalletEntity.ByMerchant.GenerateRowKey(src.Network, src.WalletAddress),
                entity =>
            {
                if (!string.IsNullOrEmpty(src.DisplayName))
                {
                    entity.DisplayName = src.DisplayName;
                }

                if (src.IncomingPaymentDefaults != null)
                {
                    entity.IncomingPaymentDefaults = src.IncomingPaymentDefaults;
                }

                if (src.OutgoingPaymentDefaults != null)
                {
                    entity.OutgoingPaymentDefaults = src.OutgoingPaymentDefaults;
                }

                return(entity);
            });

            if (updatedEntity == null)
            {
                throw new KeyNotFoundException();
            }
        }
Exemple #14
0
        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 UpdateAsync(LegalEntity legalEntity)
 {
     await _storage.MergeAsync(GetPartitionKey(), GetRowKey(legalEntity.Id), entity =>
     {
         Mapper.Map(legalEntity, entity);
         return(entity);
     });
 }
Exemple #16
0
 public Task UpdateAsync(AssetPair assetPair)
 {
     return(_storage.MergeAsync(GetPartitionKey(assetPair.Exchange), GetRowKey(assetPair.Name), entity =>
     {
         Mapper.Map(assetPair, entity);
         return entity;
     }));
 }
Exemple #17
0
 public Task UpdateAsync(MarketOrder marketOrder)
 {
     return(_storage.MergeAsync(GetPartitionKey(marketOrder.CreatedDate), GetRowKey(marketOrder.Id), entity =>
     {
         Mapper.Map(marketOrder, entity);
         return entity;
     }));
 }
        public async Task <T> MergeAsync(string partitionKey, string rowKey, Func <T, T> item)
        {
            var result = await _table.MergeAsync(partitionKey, rowKey, item);

            await _cache.MergeAsync(partitionKey, rowKey, item);

            return(result);
        }
 public async Task UpdateAsync(IDisclaimer disclaimer)
 {
     await _storage.MergeAsync(GetPartitionKey(disclaimer.LykkeEntityId), GetRowKey(disclaimer.Id), entity =>
     {
         Mapper.Map(disclaimer, entity);
         return(entity);
     });
 }
Exemple #20
0
 public async Task UpdateAsync(RemainingVolume remainingVolume)
 {
     await _storage.MergeAsync(GetPartitionKey(), GetRowKey(remainingVolume.AssetPairId), entity =>
     {
         Mapper.Map(remainingVolume, entity);
         return(entity);
     });
 }
 public async Task UpdateAsync(Instrument instrument)
 {
     await _storage.MergeAsync(GetPartitionKey(), GetRowKey(instrument.AssetPair), entity =>
     {
         Mapper.Map(instrument, entity);
         return(entity);
     });
 }
 public async Task UpdateAsync(IndexPrice indexPrice)
 {
     await _storage.MergeAsync(GetPartitionKey(), GetRowKey(indexPrice.Name), entity =>
     {
         Mapper.Map(indexPrice, entity);
         return(entity);
     });
 }
 public async Task UpdateAsync(IFileInfo fileInfo)
 {
     await _storage.MergeAsync(GetPartitionKey(fileInfo.InvoiceId), fileInfo.FileId, entity =>
     {
         Mapper.Map(fileInfo, entity);
         return(entity);
     });
 }
 public async Task UpdateAsync(SummaryReport summaryReport)
 {
     await _storage.MergeAsync(GetPartitionKey(summaryReport.AssetPairId), GetRowKey(summaryReport.TradeAssetPairId), entity =>
     {
         Mapper.Map(summaryReport, entity);
         return(entity);
     });
 }
Exemple #25
0
 public async Task UpdateAsync(Domain.AssetSettings assetSettings)
 {
     await _storage.MergeAsync(GetPartitionKey(), GetRowKey(assetSettings.AssetId), entity =>
     {
         Mapper.Map(assetSettings, entity);
         return(entity);
     });
 }
Exemple #26
0
 public async Task UpdateAsync(Position position)
 {
     await _storage.MergeAsync(GetPartitionKey(position.Exchange), GetRowKey(position.AssetId), entity =>
     {
         Mapper.Map(position, entity);
         return(entity);
     });
 }
 public async Task UpdateAsync(AssetPairLink assetPairLink)
 {
     await _storage.MergeAsync(GetPartitionKey(), GetRowKey(assetPairLink.AssetPairId), entity =>
     {
         Mapper.Map(assetPairLink, entity);
         return(entity);
     });
 }
Exemple #28
0
 public async Task <IPaymentTransaction> SetStatus(string id, PaymentStatus status)
 {
     return(await _tableStorageIndices.MergeAsync(IndexPartitinKey, id, _tableStorage, entity =>
     {
         entity.SetPaymentStatus(status);
         return entity;
     }));
 }
 public async Task UpdateAsync(PnLStopLossEngine pnLStopLossEngine)
 {
     await _storage.MergeAsync(GetPartitionKey(), GetRowKey(pnLStopLossEngine.Id), entity =>
     {
         Mapper.Map(pnLStopLossEngine, entity);
         return(entity);
     });
 }
 public async Task UpdateAsync(IndexSettings indexSettings)
 {
     await _storage.MergeAsync(GetPartitionKey(), GetRowKey(indexSettings.Name), entity =>
     {
         Mapper.Map(indexSettings, entity);
         return(entity);
     });
 }