예제 #1
0
        public TransactionModel BuyCryptoPerPiece(TransactionModel transactionModel)//user wants to buy one bitcoin
        {
            decimal cryptoPrice = _getCryptoInfoService.GetCryptoPrice(transactionModel.CryptoSymbol);
            decimal saleValue   = transactionModel.AmountToBuyOrSell * cryptoPrice;

            decimal outCashOnHand = transactionModel.USD - saleValue;

            transactionModel = bindTransactionModel(transactionModel, outCashOnHand, transactionModel.CryptoSymbol, transactionModel.AmountToBuyOrSell);

            _context.SaveChanges();

            return(transactionModel);
        }
예제 #2
0
        public TransactionModel BuyCryptoPerPiece(TransactionModel transactionModel)//user wants to buy one bitcoin
        {
            decimal cryptoPrice = _getCryptoInfoService.GetCryptoPrice(transactionModel.CryptoSymbol);
            decimal saleValue   = transactionModel.AmountToBuyOrSell * cryptoPrice;
            // run validation to see if user has enough to sell
            decimal outCashOnHand = transactionModel.USD - saleValue;

            // Console.WriteLine("######################## BUYING CRYPTO ########################");
            // Console.WriteLine("########################" + outCashOnHand + "########################");

            transactionModel = bindTransactionModel(transactionModel, outCashOnHand, transactionModel.CryptoSymbol, transactionModel.AmountToBuyOrSell);
            _context.SaveChanges();
            return(transactionModel);
        }