public void Execute(Guid id, decimal amount)
        {
            try
            {
                var account = _payAsYouGoAccountRepository.FindBy(id);

                var credit = new Money(amount);

                account.TopUp(credit, _clock);

                _payAsYouGoAccountRepository.Save(account);

                _unitOfWork.SaveChanges();
            }
            catch (ConcurrencyException ex)
            {
                _unitOfWork.Advanced.Clear();

                // TODO: Add logic to retry X times then move to an error queue
                // Execute(id, amount);

                throw ex;
            }
        }
Пример #2
0
        public void Execute(Guid id, string phoneNumber, DateTime callStart, int callLengthInMinutes)
        {
            try{
                var payAsYouGoAccount = _payAsYouGoAccountRepository.FindBy(id);

                var numberDialled = new PhoneNumber(phoneNumber);
                var phoneCall     = new PhoneCall(numberDialled, callStart, new Minutes(callLengthInMinutes));

                payAsYouGoAccount.Record(phoneCall, new PhoneCallCosting(), _clock);

                _payAsYouGoAccountRepository.Save(payAsYouGoAccount);

                _unitOfWork.SaveChanges();
            }
            catch (ConcurrencyException ex)
            {
                _unitOfWork.Advanced.Clear();

                // TODO: Add logic to retry X times then move to an error queue
                // Execute(id, phoneNumber, callStart, callLengthInMinutes);

                throw ex;
            }
        }