public async Task <bool> ProcessMessage(CoinEvent queueMessage)
        {
            switch (queueMessage.CoinEventType)
            {
            case CoinEventType.CashinCompleted:
                return(await ProcessCashIn(queueMessage));

            case CoinEventType.TransferCompleted:
            case CoinEventType.CashoutCompleted:
                return(await ProcessOutcomeOperation(queueMessage));

            default:
                return(true);
            }
        }
        private async Task <bool> ProcessCashIn(CoinEvent queueMessage)
        {
            if (queueMessage.CoinEventType != CoinEventType.CashinCompleted)
            {
                return(true);
            }

            var bcnCreds = await _bcnClientCredentialsRepository.GetByAssetAddressAsync(queueMessage.FromAddress);

            var asset = await _assetsService.TryGetAssetAsync(bcnCreds.AssetId);

            var amount = EthServiceHelpers.ConvertFromContract(queueMessage.Amount, asset.MultiplierPower, asset.Accuracy);

            await HandleCashInOperation(asset, (double)amount, bcnCreds.ClientId, bcnCreds.Address,
                                        queueMessage.TransactionHash);

            return(true);
        }
        private Task <bool> SendEventToCqrs(CoinEvent @event)
        {
            _cqrsEngine.SendCommand(new ProcessEthCoinEventCommand
            {
                Additional      = @event.Additional,
                Amount          = @event.Amount,
                CoinEventType   = @event.CoinEventType,
                ContractAddress = @event.ContractAddress,
                EventTime       = @event.EventTime,
                FromAddress     = @event.FromAddress,
                OperationId     = @event.OperationId,
                ToAddress       = @event.ToAddress,
                TransactionHash = @event.TransactionHash,
            },
                                    BoundedContexts.EthereumCommands,
                                    BoundedContexts.EthereumCommands);

            return(Task.FromResult(true));
        }
        private async Task <bool> ProcessOutcomeOperation(CoinEvent queueMessage)
        {
            var transferTx = await _ethereumTransactionRequestRepository.GetAsync(Guid.Parse(queueMessage.OperationId));

            switch (transferTx.OperationType)
            {
            case OperationType.CashOut:
                await SetCashoutHashes(transferTx, queueMessage.TransactionHash);

                break;

            case OperationType.Trade:
                await SetTradeHashes(transferTx, queueMessage.TransactionHash);

                break;
            }

            return(true);
        }