Esempio n. 1
0
        public void UpdateAccountBalance(Account account, decimal amount)
        {
            if (account == null)
            {
                throw new ArgumentNullException(nameof(account));
            }

            repo.SetBalance(account.ID, account.Balance += amount);

            repo.AddTransaction(account.ID, amount, account.Balance);

            if (account.Balance < 0)
            {
                reportingService.AccountIsOverdrawn(account.ID);
            }
        }
Esempio n. 2
0
        private void ValidateOperation(bool result, string operation, Transaction currentTransaction, TransactionViewModel model)
        {
            if (result)
            {
                _bankRepo.AddTransaction(currentTransaction);

                model.Message = $"Success: {operation} performed.";

                model.IsError = false;
            }
            else
            {
                ModelState.AddModelError("Amount", $"{operation} failed. Amount is greater than balance.");

                model.IsError = true;
            }
        }