/* * Pre: * Post: The preference is deleted from the database * @param contactId is the id of the contact that the preference is associated with * @param prefType is the type of the preference * @param preferenceValue is the value of the preference * @returns true if the preference is successfully deleted and false otherwise */ public static bool DeleteJudgePreference(int contactId, Utility.JudgePreferences prefType, string preferenceValue) { bool result = true; DataTable table = new DataTable(); SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["WmtaConnectionString"].ConnectionString); try { connection.Open(); string storedProc = "sp_JudgePreferenceDelete"; SqlCommand cmd = new SqlCommand(storedProc, connection); SqlDataAdapter adapter = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@contactId", contactId); cmd.Parameters.AddWithValue("@prefTypeId", (int)prefType); cmd.Parameters.AddWithValue("@preference", preferenceValue); adapter.Fill(table); } catch (Exception e) { Utility.LogError("DbInterfaceContact", "DeleteJudgePreference", "contactId: " + contactId + ", prefType: " + prefType + ", preferenceValue: " + preferenceValue, "Message: " + e.Message + " StackTrace: " + e.StackTrace, -1); result = false; } connection.Close(); return(result); }
/* * Pre: * Post: The input preference is deleted front the judge's list of preferences * @param preferenceType is the type of the preference to delete * @param preference is the specific preference to delete * @returns true if the preference is successfully deleted and false otherwise */ public bool deletePreference(Utility.JudgePreferences preferenceType, string preference) { bool result; JudgePreference prefToDelete = new JudgePreference(-1, preferenceType, preference); result = DbInterfaceJudge.DeleteJudgePreference(id, preferenceType, preference); if (result) { preferences.Remove(prefToDelete); } return(result); }
/* * Pre: The input contact id must exist in the database * Post: The new preference is added to the database * @param contactId is the id of the contact that the new preference is to be associated with * @param prefType is the type of the preference * @param preferenceValue is the value of the preference */ public static JudgePreference AddJudgePreference(int contactId, Utility.JudgePreferences prefType, string preferenceValue) { JudgePreference preference = null; DataTable table = new DataTable(); SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["WmtaConnectionString"].ConnectionString); try { connection.Open(); string storedProc = "sp_JudgePreferenceNew"; SqlCommand cmd = new SqlCommand(storedProc, connection); SqlDataAdapter adapter = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@contactId", contactId); cmd.Parameters.AddWithValue("@prefTypeId", (int)prefType); cmd.Parameters.AddWithValue("@preference", preferenceValue); adapter.Fill(table); if (table.Rows.Count == 1) { int prefId = Convert.ToInt32(table.Rows[0]["PreferenceId"]); preference = new JudgePreference(prefId, prefType, preferenceValue); } } catch (Exception e) { Utility.LogError("DbInterfaceContact", "AddJudgePreference", "contactId: " + contactId + ", prefType: " + prefType + ", preferenceValue: " + preferenceValue, "Message: " + e.Message + " StackTrace: " + e.StackTrace, -1); } connection.Close(); return(preference); }
/* * Pre: * Post: The new preference is added to the judge's list of preferences *@param preferenceType is the type of the new preference *@param preference is the specific preference *@returns true if the preference was successfully added and false otherwise */ public bool addPreference(Utility.JudgePreferences preferenceType, string preference) { bool result = true; JudgePreference newPref = DbInterfaceJudge.AddJudgePreference(id, preferenceType, preference); if (preferences == null) { preferences = new List <JudgePreference>(); } if (newPref != null) { preferences.Add(newPref); } else { result = false; } return(result); }
public JudgePreference(int preferenceId, Utility.JudgePreferences preferenceType, string preference) { this.preferenceId = preferenceId; this.preferenceType = preferenceType; this.preference = preference; }