private void btnSave_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(tbName.Text) || string.IsNullOrEmpty(tbName.Name)) { MessageBox.Show("Please enter a name for the alert to check.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (lbConditions.Items.Count == 0) { MessageBox.Show("Please enter at least one alert to check.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (!_actionSet) { MessageBox.Show("Please select the action desired upon criteria match.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } Alert newCondition = new Alert { Name = tbName.Text, Description = tbDescription.Text, Enabled = (bool)chbEnabled.IsChecked, Action = fap.GetAction(), Criterias = new List <Criteria>(), lights = fap.GetSelectedLights(), Url = tbUrl.Text }; foreach (Criteria t in lbConditions.Items) { newCondition.Criterias.Add(t); } if (_oldName != null) { RssFeedAlertHandler.DeleteFeedAlert(_oldName); } if (RssFeedAlertHandler.SaveFeedAlert(newCondition)) { DialogResult = true; Close(); } else { MessageBox.Show("Therer was an error while saving the current Rss Feed Alert.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }