示例#1
0
        public bool ChargeMoney(int id, decimal amount)
        {
            IPersonRepository repository = null;

            IBankAccount bankaccount = null;

            INotifier notifier = null;

            var person = repository.Find(id);

            if (person != null)
            {
                var accountsummary = bankaccount.SearchAccountSummary(person);

                if (accountsummary != null)
                {
                    if (accountsummary.Total > amount)
                    {
                        var transaction = bankaccount.Charge(person, amount);

                        if (transaction != null)
                        {
                            notifier.Notify(transaction, person);

                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        public bool ChargeMoneyHappyPath(int id, decimal amount)
        {
            var person = _repository.Find(id);

            var accountsummary = _bankaccount.SearchAccountSummary(person);

            if (accountsummary.Total > amount)
            {
                var transaction = _bankaccount.Charge(person, amount);

                _notifier.Notify(transaction, person);

                return(true);
            }
            else
            {
                return(false);
            }
        }