private void ImportMunicipalitiesFromFileButton_Click(object sender, RoutedEventArgs e) { var municipalityFilePath = MunicipalityImportFilePath.Text; if (string.IsNullOrWhiteSpace(municipalityFilePath) || !File.Exists(municipalityFilePath) || Path.GetExtension(municipalityFilePath) != ".txt") { MessageBox.Show("You need to select or enter a path to a .txt file"); return; } var api = new ApiConsumer(); MessageBox.Show(api.ImportMunicipalities(municipalityFilePath) ? "Successfully imported" : "Import failed"); }
private void ImportMunicipalitiesByNameButton_Click(object sender, RoutedEventArgs e) { var municipalityList = MunicipalityImportByNameTextBox.Text.Split(Environment.NewLine.ToCharArray()).Where(a => !string.IsNullOrWhiteSpace(a)).ToList(); if (!municipalityList.Any()) { MessageBox.Show("You need to enter municipality names separated by new lines to the text field"); return; } var api = new ApiConsumer(); var result = api.ImportMunicipalities(municipalityList); MessageBox.Show(result ? "Successfully imported" : "Import failed"); }