public IActionResult OnPostDepositCoins()
        {
            UserId             = User.FindFirstValue(ClaimTypes.NameIdentifier);
            AcceptedCoinsValue = _sodaMachineLogic.AcceptedCoinValues;

            if (AcceptedCoinsValue.Contains(SelectedCoinValue))
            {
                _sodaMachineLogic.MoneyInserted(UserId, SelectedCoinValue);

                UserCredit = _sodaMachineLogic.GetMoneyInsertedTotal(UserId);
            }

            return(OnGet());
        }
        private static void DepositMoney()
        {
            Console.WriteLine("How much would you like to add to the machine?");

            string amountText = Console.ReadLine();

            bool isValidAmount = decimal.TryParse(amountText, out decimal amountAdded);

            _sodaMachine.MoneyInserted(userId, amountAdded);
        }
        // Used for depositing coins
        public IActionResult OnPost()
        {
            UserId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (Deposit > 0)
            {
                _sodaMachine.MoneyInserted(UserId, Deposit);
            }

            return(RedirectToPage());
        }
Exemple #4
0
        private static void DepositMoney()
        {
            Console.Clear();

            // Get what coin to deposit
            Console.WriteLine("How much would you like to add to the machine: ");
            string amountText = Console.ReadLine();

            bool isValidamount = decimal.TryParse(amountText, out decimal amountAdded);

            // Deposit that amount
            _sodaMachine.MoneyInserted(userId, amountAdded);
        }