private void ButtonUpdateJob_Click(object sender, RoutedEventArgs e) { JobDomain jobDomain = (JobDomain)ListJobDomain.SelectedItem; Job job = (Job)ListJob.SelectedItem; JobDataContext jobDataContext = new JobDataContext(); jobDataContext.Job = job; jobDataContext.JobDomains = new ObservableCollection<JobDomain>(db.JobDomain.ToList()); if (job != null) { JobWindow jobWindow = new JobWindow(db); jobWindow.DataContext = jobDataContext; jobWindow.ShowDialog(); if (jobWindow.DialogResult == true) { db.SaveChanges(); } } else { MessageBox.Show("Veuillez sélectionner un métier."); } }
private void ButtonAddJob_Click(object sender, RoutedEventArgs e) { Job job = new Job(); job.JobDomain = (JobDomain)ListJobDomain.SelectedItem; JobDataContext jobDataContext = new JobDataContext(); jobDataContext.Job = job; jobDataContext.JobDomains = new ObservableCollection<JobDomain>(db.JobDomain.ToList()); JobWindow jobWindow = new JobWindow(db); jobWindow.DataContext = jobDataContext; jobWindow.ShowDialog(); if (jobWindow.DialogResult == true) { Jobs.Add(job); db.Job.Add(job); db.SaveChanges(); } }