Esempio n. 1
0
        private static void RecordWithdrawOperation(AtmDbContext context, CardAccount account, decimal amount)
        {
            context.TransactionsHistory.Add(new TransactionHistory
            {
                CardNumber = account.CardNumber,
                TransactionDate = DateTime.Now,
                Amount = amount
            });

            context.SaveChanges();
        }
Esempio n. 2
0
        private static void CheckForEnoughFunds(CardAccount account, decimal amount)
        {
            if (account == null)
            {
                throw new ArgumentNullException("account", "There is no such account in the DB");
            }

            if (account.CardCash < amount)
            {
                throw new ArgumentException("Not enough funds available in the selected account.", "amount");
            }
        }
Esempio n. 3
0
        private static void ValidateAccount(CardAccount account, string pin)
        {
            if (account == null)
            {
                throw new ArgumentNullException("account", "There is no such account in the DB");
            }

            if (account.CardPIN != pin)
            {
                throw new ArgumentException("Invalid PIN for the selected account provided.", "pin");
            }
        }