A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Transactions for Cart and custom tables

Vote:
 

Hi,

I'm using EPiServer Commerce 7.6 and want to create a transaction that spans changes to a cart/purchaseorder and an update to a custom table using SqlHelper.ExecuteReader. 

I've tried using the TransactionScope from MediaChase.Provider.Data which works for the cart.AcceptChanges but not for the custom table, and when I use SqlContext.Current.BeginTransaction()/SqlContext.CurrentTransaction.Commit() (see below) it works for my custom table but not cart.AcceptChanges().

 

SqlContext.Current.BeginTransaction();

try
{
	if (order.GetWMSeReceiptId() == -1)
	{
// Update of custom table containing a sequence number var receiptId = ConfigurationHelpers.ReceiptId(SqlContext.Current.Transaction); order.SetWMSeReceiptId((int) receiptId); var receiptNumber = IntegrationHelpers.GetReceiptStoreRunningNumber(order); order.SetWMSeReceiptNumber(receiptNumber); order.AcceptChanges(); } _service.SendReceipt(order); order.SetWebShopOrderStatus("WMSeReceiptSent"); order.AcceptChanges(); receiptsSent++; SqlContext.Current.Transaction.Commit(); } catch (Exception exception) { SqlContext.Current.Transaction.Rollback(); throw; }


Any tips?

Brgds

Jonas
#85023
Apr 11, 2014 10:45
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.