public long SavePayment(IEnumerable <PaymentInstrument> paymentInstruments, string notes, long dataRecorderCreatorId) { if (paymentInstruments == null || !paymentInstruments.Any() || paymentInstruments.Contains(null)) { throw new InvalidOperationException("The payment must include at least one payment instrument, and may not contain null payment instruments"); } var payment = new Payment { Notes = notes, DataRecorderMetaData = _dataRecorderMetaDataFactory. CreateDataRecorderMetaData(dataRecorderCreatorId, DateTime.Now) }; using (var scope = new TransactionScope()) { payment = _paymentRepository.Save(payment); foreach (var paymentInstrument in paymentInstruments) { paymentInstrument.PaymentId = payment.Id; } _combinedPaymentInstrumentRepository.SavePaymentInstruments(paymentInstruments); scope.Complete(); } return(payment.Id); }