Exemple #1
0
        /// <summary>
        /// Do actual delete.
        /// </summary>
        /// <param name="tradingSupport">The trading support client.</param>
        private void CommitDelete(TradingSupportClient tradingSupport)
        {
            if (this.DebtRuleId != null)
            {
                Boolean inUse = false;

                lock (DataModel.SyncRoot)
                    inUse = DataModel.DebtClass.Any(row => !row.IsDebtRuleIdNull() && row.DebtRuleId == this.DebtRuleId);

                if (!inUse)
                {
                    MethodResponseErrorCode response = tradingSupport.DeleteDebtRule(new TradingSupportReference.DebtRule[] {
                        new TradingSupportReference.DebtRule()
                        {
                            RowId = this.DebtRuleId.Value, RowVersion = this.RowVersion
                        }
                    });

                    if (!response.IsSuccessful && (response.Errors.Length == 0 || response.Errors[0].ErrorCode != ErrorCode.Deadlock))
                    {
                        GuardianObject.ThrowErrorInfo(response.Errors[0]);
                    }
                }
                else
                {
                    throw new DebtRuleInUseException(this.Name, "Cannot delete a debt rule that is currently in use.");
                }
            }
        }