logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
Joe Payne @ Solunar  
#1 Posted : Monday, March 28, 2022 3:16:45 PM(UTC)
Joe Payne @ Solunar

Rank: Member

Groups: Developers, Registered, HelpDesk
Joined: 11/7/2018(UTC)
Posts: 23

Thanks: 5 times
In the code below, a SQL transaction is initiated inside the try/catch. If an exception is thrown, the SQL transaction never gets told to roll back. Shouldn't the catch be doing a SQL rollback?

This is the /Areas/Admin/Controllers/HelpController.cs

Code:

        public ActionResult DeleteSelected(FormCollection form)
        {
            List<int> errorIds = new List<int>();
            if (form.Keys.Count > 0)
            {
                try
                {
                    var selectedKeys = form.AllKeys.Where(key => key.ToUpper().StartsWith("ERROR_CHK_",
                        StringComparison.InvariantCultureIgnoreCase)).Where(x => form[x].Contains("true")).ToList();

                    foreach (var key in selectedKeys)
                    {
                        errorIds.Add(AlwaysConvert.ToInt(key.Substring(10)));
                    }

                    IDatabaseSessionManager database = AbleContext.Current.Database;
                    database.BeginTransaction();
                    foreach (int cid in errorIds)
                    {
                        var error = _errorMessageRepo.Load(cid);
                        _errorMessageRepo.Delete(error);
                    }
                    database.CommitTransaction();

                }
                catch (Exception exp)
                {
                    Logger.Error(exp.Message, exp);
                }
            }

            return ErrorLogList();
        }
Joe Payne, AbleMods Hosting LLC
https://www.ablemodshosting.com

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

Users browsing this topic
Guest (4)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.