protected void btnSaveNewAlert_Click(object sender, EventArgs e) { // Parse the dates int From_Year = Parsers.ParseInt(drpYear_From.Text); int From_Month = Parsers.ParseInt(drpMonth_From.Text); int From_Day = Parsers.ParseInt(txtDay_From.Text); int From_Hour = Parsers.ParseInt(txtHour_From.Text);; int From_Minute = Parsers.ParseInt(txtMinute_From.Text); DateTime FromDate = new DateTime(From_Year, From_Month, From_Day, From_Hour, From_Minute, 0); int To_Year = Parsers.ParseInt(drpYear_To.Text); int To_Month = Parsers.ParseInt(drpMonth_To.Text); int To_Day = Parsers.ParseInt(txtDay_To.Text); int To_Hour = Parsers.ParseInt(txtHour_To.Text);; int To_Minute = Parsers.ParseInt(txtMinute_To.Text); DateTime ToDate = new DateTime(To_Year, To_Month, To_Day, To_Hour, To_Minute, 0); int importance_int = Parsers.ParseInt(drpImportance.Text); string alertContent = txtAlertContent.Text; AlertImportance importance = AlertImportance.Normal; if (importance_int > 0) { importance = AlertImportance.High; } if (!string.IsNullOrEmpty(alertContent)) { Alert newAlert = new Alert() { Content = alertContent, DisplayFrom = FromDate, DisplayTo = ToDate, Importance = importance }; AlertRepository alertRepo = new AlertRepository(); alertRepo.Insert(newAlert); Response.Redirect(Request.RawUrl); } }
private Alert dbDataReaderToAlert(SqlDataReader dbDataReader) { int parsedImportance = Parsers.ParseInt(dbDataReader["importance"].ToString()); AlertImportance AlertImportance = AlertImportance.Normal; if (parsedImportance > 0) { AlertImportance = AlertImportance.High; } return(new Alert() { ID = Parsers.ParseInt(dbDataReader["id"].ToString()), Content = dbDataReader["text"].ToString(), DisplayFrom = Parsers.ParseDate(dbDataReader["display_from"].ToString()), DisplayTo = Parsers.ParseDate(dbDataReader["display_to"].ToString()), Importance = AlertImportance }); }