Ejemplo n.º 1
0
        public IActionResult Edit(long Id)
        {
            var response = _cryptoAdapterService.GetCryptoAdapter(Id);

            if (response.Status == StatusEnum.Error)
            {
                return(BadRequest());
            }

            return(PartialView("_EditPartial", response.Value));
        }
        public async Task <Response <List <TransactionResponse <BlockchainTransactionModel> > > > SendToBlockchain(BlockchainDataModel blockchainDataModel)
        {
            var response = new Response <List <TransactionResponse <BlockchainTransactionModel> > >()
            {
                Value = new List <TransactionResponse <BlockchainTransactionModel> >()
            };

            try
            {
                var jobTimeLine = _entities.JobTimeline.FirstOrDefault(jt => jt.Id == blockchainDataModel.JobId);

                var cryptoAdapterId = jobTimeLine.Schedule.JobDefinition.Adapter1.CryptoAdapter.FirstOrDefault().Id;

                var cryptoAdapter = _cryptoAdapterService.GetCryptoAdapter(cryptoAdapterId);

                if (cryptoAdapter.Status != StatusEnum.Success)
                {
                    return(response);
                }

                switch (cryptoAdapter.Value.NodeType)
                {
                case AdapterTypeItemEnum.Cardano:
                    var cardano = new CardanoAdapter();

                    break;

                case AdapterTypeItemEnum.EOS:
                    var eos = new EOSAdapter();

                    break;

                case AdapterTypeItemEnum.Ethereum:
                    var ethAdapter = new EthereumAdapter(_logger);

                    response = await ethAdapter.SendTransactions(blockchainDataModel.Transactions, cryptoAdapter.Value);

                    break;

                case AdapterTypeItemEnum.NEO:
                    var neo = new NEOAdapter(_logger);

                    break;

                case AdapterTypeItemEnum.Bitcoin:
                    var btcAdapter = new BitcoinAdapter(_logger);

                    break;
                }
            }
            catch (Exception ex)
            {
                _logger.Information($"BlockchainService.SendToBlockchain(blockchainDataModel: {blockchainDataModel})");
                _logger.Error(ex.Message);
                response.Status = StatusEnum.Error;
            }

            return(response);
        }