Example #1
0
        public void Sell_BTCTest()
        {
            User    test    = new MoneyTransfer657.User("Erik Lomas");
            decimal btc_bal = test.Btc;

            test.Sell_BTC(1m);
            Assert.AreEqual(test.Btc, (btc_bal - 1m));
        }
Example #2
0
        private void SellCoinButton_Click(object sender, RoutedEventArgs e)
        {
            decimal amount_to_sell;
            bool    isNumeric = decimal.TryParse(coinBuySellAmountTextBox.Text, out amount_to_sell);

            if (isNumeric == false)
            {
                MessageBox.Show("Only enter numbers for amount of coins to buy/sell");
                return;
            }
            if (selectCoinComboBox.SelectedIndex == 0)
            {
                if (amount_to_sell > user.Btc)
                {
                    MessageBox.Show("You dont have that much BTC to sell");
                    return;
                }
                Thread sell = new Thread(() =>
                {
                    user.Sell_BTC(amount_to_sell);
                    user.Add_Transaction(user.Username, "global", "BTC", amount_to_sell.ToString(), "sell crypto");
                });
                sell.Start();
                sell.Join();
            }
            else if (selectCoinComboBox.SelectedIndex == 1)
            {
                if (amount_to_sell > user.Eth)
                {
                    MessageBox.Show("You dont have that much ETH to sell");
                    return;
                }
                Thread sell = new Thread(() =>
                {
                    user.Sell_ETH(amount_to_sell);
                    user.Add_Transaction(user.Username, "global", "ETH", amount_to_sell.ToString(), "sell crypto");
                });
                sell.Start();
                sell.Join();
            }
            else if (selectCoinComboBox.SelectedIndex == 2)
            {
                if (amount_to_sell > user.Xrp)
                {
                    MessageBox.Show("You dont have that much XRP to sell");
                    return;
                }
                Thread sell = new Thread(() =>
                {
                    user.Sell_XRP(amount_to_sell);
                    user.Add_Transaction(user.Username, "global", "XRP", amount_to_sell.ToString(), "sell crypto");
                });
                sell.Start();
                sell.Join();
            }
            else
            {
                MessageBox.Show("Please select a coin before buying or selling.");
            }
            Update_Owned();
            MessageBox.Show("Sale Complete");
        }