private void DoSave() { _eventAggregator.GetEvent <GeneralMessageEvent>().Publish(ApplicationStrings.BeginningSave); ExecuteFaultHandledOperation(() => { var invoiceService = _serviceFactory.CreateClient <IInvoiceService>(); using (var scope = new TransactionScope()) //TransactionScopeAsyncFlowOption.Enabled { using (invoiceService) { if (Invoice.InvoiceKey == 0) { var accountService = _serviceFactory.CreateClient <IAccountService>(); Invoice.InvoiceNumber = accountService.GetAccountNextNumber(Invoice.Account.Model, QIQOEntityNumberType.InvoiceNumber); accountService.Dispose(); } //TODO: Do something to make sure the order items are in the object properly var new_order_line = Invoice.InvoiceItems.Where(item => item.ProductKey == 0).FirstOrDefault(); if (new_order_line != null) { Invoice.InvoiceItems.Remove(new_order_line); } // For some reason, these don't seem to get set properly when I add the account object to the Invoice object Invoice.Model.InvoiceItems.ForEach(item => item.OrderItemBillToAddress = DefaultBillingAddress.Model); Invoice.Model.InvoiceItems.ForEach(item => item.OrderItemShipToAddress = DefaultShippingAddress.Model); var orderKey = invoiceService.CreateInvoice(Invoice.Model); if (Invoice.InvoiceKey == 0) { Invoice.InvoiceKey = orderKey; } ViewTitle = Invoice.InvoiceNumber; Invoice.AcceptChanges(); } scope.Complete(); } }); if (Invoice.InvoiceKey > 0) { _eventAggregator.GetEvent <InvoiceUpdatedEvent>().Publish($"Invoice {Invoice.InvoiceNumber} updated successfully"); _workingInvoiceService.CloseInvoice(Invoice); _regionManager.RequestNavigate(RegionNames.ContentRegion, ViewNames.InvoiceHomeView); } }