ActivEarth.DAO.ContestDAO.RemoveOldContests C# (CSharp) Метод

RemoveOldContests() публичный статический Метод

Removes contests from the DB that have were deactivated more than two weeks ago.
public static RemoveOldContests ( ) : bool
Результат bool
        public static bool RemoveOldContests()
        {
            int daysToExpire = 14;

            try
            {
                using (SqlConnection connection = ConnectionManager.GetConnection())
                {
                    var data = new ActivEarthDataProvidersDataContext(connection);
                    List<ContestDataProvider> dbContests =
                        (from c in data.ContestDataProviders
                         where
                             (c.deactivated != null &&
                             c.deactivated.Value.Subtract(DateTime.Now) > new TimeSpan(daysToExpire, 0, 0, 0))
                         select c).ToList();

                    foreach (ContestDataProvider dbContest in dbContests)
                    {
                        data.ContestDataProviders.DeleteOnSubmit(dbContest);
                        data.SubmitChanges();
                    }

                    return true;
                }
            }
            catch (Exception)
            {
                return false;
            }
        }