/// <summary> /// Creates a new settings entry for a candidate and adds it to the persistence storage medium. /// </summary> /// <param name="candidateId">The CFIS ID of the candidate to whom this preference applies.</param> /// <param name="isPaperless">Whether or not the candidate has a paperless preference.</param> /// <param name="username">The C-Access username of the updating user.</param> /// <returns>A new <see cref="CmoSettings"/> object if the settings were added successfully; otherwise, null.</returns> public CmoSettings AddCmoSettings(string candidateId, bool isPaperless, string username) { using (CmoSettingsTableAdapter ta = new CmoSettingsTableAdapter()) { return((Convert.ToInt32(ta.SetData(candidateId, isPaperless, username, new byte[0])) > 0) ? GetCmoSettings(ta, candidateId) : null); } }
/// <summary> /// Gets the C-Access Campaign Message Online settings for a specific candidate. /// </summary> /// <param name="adapter">A <see cref="CmoSettingsTableAdapter"/> for access to storage medium.</param> /// <param name="candidateId">The CFIS ID of the candidate to query.</param> /// <returns>The specified candidate's Campaign Messages Online settings if one exists; otherwise, null.</returns> private CmoSettings GetCmoSettings(CmoSettingsTableAdapter adapter, string candidateId) { using (CmoSettingsTds ds = new CmoSettingsTds()) { if (adapter == null) { using (adapter = new CmoSettingsTableAdapter()) { adapter.FillBy(ds.CmoSettings, candidateId); } } else { adapter.FillBy(ds.CmoSettings, candidateId); } foreach (CmoSettingsTds.CmoSettingsRow row in ds.CmoSettings.Rows) { CmoSettings cos; if (TryParse(row, out cos)) { return(cos); } } } return(null); }
/// <summary> /// Saves a CMO message in the persistence storage medium by overwriting the existing record. /// </summary> /// <param name="settings">The CMO settings to update.</param> /// <returns>true if this instance was saved successfuly; otherwise, false.</returns> public bool Update(CmoSettings settings) { if (settings == null) { return(false); } using (CmoSettingsTableAdapter ta = new CmoSettingsTableAdapter()) { return((Convert.ToInt32(ta.SetData(settings.CandidateID, settings.IsPaperless, settings.UpdaterUserName, settings.Version)) > 0) ? true : false); } }