private void ImportEnvironmentWindowSaveButton_OnClick(object sender, RoutedEventArgs e) { bool canSave = true; if (_viewModel.IsSaveButtonEnabled) { foreach (var environment in _viewModel.NewEnvironments) { if (!(environment.EnvironmentVariables.All(v => v.IsValid == null || v.IsValid == true) && !string.IsNullOrWhiteSpace(environment.Name))) { canSave = false; } } if (canSave) { var inserted = _viewModel.SaveEnvironments(); foreach (var environment in inserted) { EnvironmentSaved?.Invoke(this, new EnvironmentSavedEventArgs(environment)); } } else { // TODO use a more descriptive message MessageBox.Show(ChamiUIStrings.ValidationFailedMessageBoxText, ChamiUIStrings.ValidationFailedMessageBoxCaption); } Close(); } }
private void NewEnvironmentWindowSaveButton_OnClick(object sender, RoutedEventArgs e) { if (_viewModel.IsSaveButtonEnabled && _viewModel.Environment.EnvironmentVariables.All(v => v.IsValid == null || v.IsValid == true) && !string.IsNullOrWhiteSpace(_viewModel.EnvironmentName) ) { var inserted = _viewModel.SaveEnvironment(); EnvironmentSaved?.Invoke(this, new EnvironmentSavedEventArgs(inserted)); Close(); } else { MessageBox.Show(ChamiUIStrings.ValidationFailedMessageBoxText, ChamiUIStrings.ValidationFailedMessageBoxCaption); } }