Exemple #1
0
        public Main()
        {
            InitializeComponent();
            try
            {
                String hotWalletAddress = cardClient.GetHotWalletAddress();

                if (!String.IsNullOrEmpty(hotWalletAddress))
                {
                    // No Sale or Transfers
                    btnSell.Enabled = false;
                }

                DCDiagnostics.TerminalSettings settings = diagnosticClient.GetSettings(this.TerminalId);

                this.CryptoCurrency = new Models.Bitcoin(settings.DefaultFiatCurrency);
                DCExchange.ExchangeClient ExchangeClient = new DCExchange.ExchangeClient();

                this.AtmMargin = ExchangeClient.GetMargin(settings.DefaultFiatCurrency, this.TerminalId);
            }
            catch (Exception ex)
            {
                GeneralExceptions("Initialise", System.Diagnostics.TraceEventType.Critical, ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// Get quote off our exchange.  Note the exchange adds margin based on terminal id.
        /// </summary>
        /// <param name="fiatAmount"></param>
        /// <returns></returns>
        public Models.Quote GetQuote(Int32 fiatAmount)
        {
            if (fiatAmount > 0)
            {
                // CryptoCurrency.Amount = Convert.ToDecimal(txtFiat.Text);
                using (DCExchange.ExchangeClient ExchangeClient = new DCExchange.ExchangeClient())
                {
                    //This method gets the buy and sell prices off 1.0 unit.
                    DCExchange.Margin margin = ExchangeClient.GetMargin(this.Settings.DefaultFiatCurrency, TerminalId);

                    Decimal rate = 0.0M;

                    if (Operation == Enums.State.Buy)
                    {
                        rate = margin.Buy;
                        CryptoCurrency.Amount = Convert.ToDecimal(fiatAmount) * margin.Buy;
                        CryptoCurrency.Fiat   = Convert.ToDecimal(fiatAmount);
                    }
                    else if (Operation == Enums.State.Sell)
                    {
                        rate = margin.Sell;
                        CryptoCurrency.Amount = Convert.ToDecimal(fiatAmount) * margin.Sell;
                        CryptoCurrency.Fiat   = Convert.ToDecimal(fiatAmount);
                    }

                    Models.Quote currentQuote = new Models.Quote()
                    {
                        Amount = CryptoCurrency.Amount,
                        Rate   = rate
                    };

                    return(currentQuote);
                }
            }
            else
            {
                throw new ArgumentOutOfRangeException();
            }
        }