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; } }
public PhoneCall(PhoneNumber numberDialled, DateTime callStart, Minutes callLength) { NumberDialled = numberDialled; Minutes = callLength; StartTime = callStart; }