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

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

Deletes an existing Contest from the DB.
public static RemoveContestFromContestId ( int contestId ) : bool
contestId int ID for the Contest whose record needs to be removed.
Результат bool
        public static bool RemoveContestFromContestId(int contestId)
        {
            try
            {
                using (SqlConnection connection = ConnectionManager.GetConnection())
                {
                    var data = new ActivEarthDataProvidersDataContext(connection);
                    ContestDataProvider dbContest =
                        (from c in data.ContestDataProviders where c.id == contestId select c).FirstOrDefault();
                    if (dbContest != null)
                    {
                        data.ContestDataProviders.DeleteOnSubmit(dbContest);
                        data.SubmitChanges();
                    }

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