コード例 #1
0
        public async Task <IActionResult> SellCrypto(string cryptoSymbol, decimal amountOnHand)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }
            if (cryptoSymbol == null)
            {
                cryptoSymbol = "LTC";
            }

            var transaction = new TransactionModel
            {
                USD          = user.USD,
                BTC          = user.BTC,
                ETH          = user.ETH,
                LTC          = user.LTC,
                DOGE         = user.DOGE,
                CryptoSymbol = cryptoSymbol,
            };

            SellViewModel sell = new SellViewModel
            {
                CryptoSymbol = transaction.CryptoSymbol,
                CryptoPrice  = _getCryptoInfoService.GetCryptoPrice(transaction.CryptoSymbol),
                AmountToSell = transaction.AmountToBuyOrSell,
                AmountOnHand = transaction.AmountOnHand,
                USD          = transaction.USD
            };


            return(View(sell));
        }
コード例 #2
0
        public async Task <IActionResult> SellCrypto(string cryptoSymbol, decimal amountOnHand)
        {
            var user = await _userManager.GetUserAsync(User);

            if (cryptoSymbol == null)
            {
                cryptoSymbol = "LTC";
            }

            var transaction = new TransactionModel
            {
                USD          = user.USD,  //the amount of cash available to spend
                BTC          = user.BTC,  //Number of crypto owned
                ETH          = user.ETH,  //Number of crypto owned
                LTC          = user.LTC,  //Number of crypto owned
                DOGE         = user.DOGE, //Number of crypto owned
                CryptoSymbol = cryptoSymbol,
            };

            SellViewModel sell = new SellViewModel
            {
                CryptoSymbol = transaction.CryptoSymbol,
                CryptoPrice  = _getCryptoInfoService.GetCryptoPrice(transaction.CryptoSymbol),
                AmountToSell = transaction.AmountToBuyOrSell,
                AmountOnHand = transaction.AmountOnHand,
                USD          = transaction.USD
            };

            return(View(sell));
        }