public void AddFee(IProcessExecutionContext executionContext, IWorkSession session, IFee fee, decimal quantity = 1) { try { // check to see if the related fee is already in the list. If so we will update that item rather than create // a new one. var transactionFee = FeeList.Where(r => r.Fee.Id == fee.Id).FirstOrDefault(); if (transactionFee is null) { var transactionFeeRecord = DataConnector.CreateTransactionFee( executionContext.DataService, Transaction, fee as IRecordPointer <Guid>, fee.Name, quantity); transactionFee = new TransactionFee(transactionFeeRecord, fee); FeeList.Add(transactionFee); } else { transactionFee.IncrementQuantity(quantity); } var priceCalculator = PriceCalculatorFactory.CreatePriceCalculator(executionContext, session, Transaction); transactionFee.CalculatePrice(executionContext, priceCalculator); DataConnector.UpdateTransactionFee(executionContext.DataService, transactionFee); } catch (Exception ex) { throw ex; } }