void btnSave_Click(object sender, EventArgs e) { try { foreach (ListItem item in cblstPreferneces.Items) { Preference preference = PreferenceManager.GetPreference(item.Value); if (preference != null) { PreferenceManager.UpdatePreference(preference.ID, item.Selected); } else { preference = new Preference { IsEnabled = item.Selected, Name = item.Value, PortalID = CMSContext.PortalID, }; PreferenceManager.Add(preference); } } FillPreferencesList(); } catch (Exception ex) { dvProblems.Visible = true; dvProblems.InnerText = ex.ToString(); upnlPreferenceItem.Update(); } }
internal static int Add(Preference preference) { using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString)) { SqlCommand sqlCommand = new SqlCommand(SN_PREFERENCE_ADD, sqlConnection); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter sqlParameter = null; sqlParameter = new SqlParameter(PN_PREFERENCE_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Output; sqlParameter.Value = preference.ID; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PREFERENCE_NAME, System.Data.SqlDbType.NVarChar); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = preference.Name; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PREFERENCE_PORTAL_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = preference.PortalID; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_PREFERENCE_IS_ENABLED, System.Data.SqlDbType.Bit); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = preference.IsEnabled; sqlCommand.Parameters.Add(sqlParameter); try { sqlCommand.Connection.Open(); sqlCommand.ExecuteNonQuery(); sqlCommand.Connection.Close(); preference.ID = Convert.ToInt32(sqlCommand.Parameters[PN_PREFERENCE_ID].Value); } catch (Exception ex) { throw ex; } } return preference.ID; }
public static int Add(Preference preference) { return PreferenceDataMapper.Add(preference); }
internal static void FillFromReader(Preference Preference, SqlDataReader reader) { int colIndex = 0; colIndex = reader.GetOrdinal(CN_PREFERENCE_ID); if (!reader.IsDBNull(colIndex)) Preference.ID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PREFERENCE_PORTAL_ID); if (!reader.IsDBNull(colIndex)) Preference.PortalID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_PREFERENCE_NAME); if (!reader.IsDBNull(colIndex)) Preference.Name = reader.GetString(colIndex); colIndex = reader.GetOrdinal(CN_PREFERENCE_IS_ENABLED); if (!reader.IsDBNull(colIndex)) Preference.IsEnabled = reader.GetBoolean(colIndex); }
internal static AJH.CMS.Core.Entities.Preference GetPreference(List<AJH.CMS.Core.Entities.Preference> Preferences, SqlDataReader reader) { int colIndex = 0; colIndex = reader.GetOrdinal(CN_PREFERENCE_ID); int value = reader.GetInt32(colIndex); AJH.CMS.Core.Entities.Preference Preference = Preferences.Where(c => c.ID == value).FirstOrDefault(); if (Preference == null) { Preference = new AJH.CMS.Core.Entities.Preference(); Preferences.Add(Preference); } return Preference; }