void DoImport(string[] fileNames) { var list = new List <IEnumerable <Applicant> >(); foreach (var fileName in fileNames) { try { list.Add(CsvHelper.ImportCsvFile(fileName)); } catch (Exception ex) { Dispatcher.Invoke(() => MessageBox.Show(string.Format(_errorImportFile, fileName, ex), Title)); } } var db = new ApplicantsDbContext(); try { foreach (var l in list) { foreach (var i in l) { db.Insert(i); } } } catch (Exception ex) { Dispatcher.Invoke(() => MessageBox.Show(string.Format(_erorImport, ex), Title)); } }
void AddCommandExecuted(object sender, ExecutedRoutedEventArgs e) { var db = new ApplicantsDbContext(); var n = new Applicant() { ApplicantId = Guid.NewGuid() }; try { db.Insert(n); } catch (Exception ex) { MessageBox.Show(string.Format(_erroradding, ex), Title); } finally { ReloadData(); _viewModel.Current = _viewModel.Applicants.FirstOrDefault(a => a.ApplicantId == n.ApplicantId); } }