public Dozent UpdateDozent(Dozent editedDozent) { var updatedDozent = (from d in _db.Dozents where d.DozentId == editedDozent.DozentId select d).Single(); updatedDozent.DozentNachname = editedDozent.DozentNachname; updatedDozent.DozentVorname = editedDozent.DozentVorname; updatedDozent.AkadGrad = editedDozent.AkadGrad; try { _db.Entry(updatedDozent).State = EntityState.Modified; _db.SaveChanges(); MessageBox.Show("Dozent wurde erfolgreich speichert!", "Erfolg", MessageBoxButton.OK, MessageBoxImage.None); } catch (DbUpdateConcurrencyException ex) { // Update the values of the entity that failed to save from the database ex.Entries.Single().Reload(); MessageBox.Show("Der Datensatz, an dem Sie arbeiten, wurde von einem anderen Benutzer geändert. Die neuen Werte für diesen Datensatz werden jetzt aktualisiert." + Environment.NewLine + "Änderungen, die Sie vorgenommen haben, wurden nicht gespeichert. Bitte erneut einreichen.", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); } return(updatedDozent); }
public Dozent CreateDozent(Dozent dozent) { var dozentnew = _db.Dozents.Add(dozent); _db.SaveChanges(); return(dozentnew); }
public void Remove(Dozent dozent) { foreach (Semester semester in this) { semester.Remove(dozent); } }
// Initializes a new instance of the DozentViewModel class. public DozentViewModel(IDozentDB dozentDB, IDialogService dialogservice) { try { _dozentDB = dozentDB; _dialogservice = dialogservice; CurrentDozent = new Dozent(); // Get list of all Dozents from dozents table DozentList = new ObservableCollection <Dozent>(); DozentList = _dozentDB.GetAllDozents(); //Open new window to add new dozent ShowAddDozentCommand = new RelayCommand(ShowAddDozentViewExecute); SaveDozentCommand = new RelayCommand(SaveDozentExecute, CanSaveDozent); CancelDozentCommand = new RelayCommand(CancelDozentExecute); DeleteDozentCommand = new RelayCommand(DeleteDozentExecute, CanDeleteDozent); RefreshCommand = new RelayCommand(RefreshExecute); SelectedDozent = DozentList[0]; CurrentDozent.IsOkChanged += OnTempSelectedDozentPropertyChanged; } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void Remove(Dozent dozent) { foreach (Studiengang studiengang in this) { studiengang.SemesterListe.Remove(dozent); } }
private OrganiserMember InitLecturer(TimeTableDbContext db, Dozent dozent, ActivityOrganiser organiser) { var n = organiser.Members.Count(l => l.ShortName.Equals(dozent.DozentID)); if (n > 1) { return(null); } var lecturer = organiser.Members.FirstOrDefault(l => l.ShortName.Equals(dozent.DozentID)); if (lecturer == null) { string profileUrl = null; if (dozent.Typ.ToUpper().Equals("PROF")) { profileUrl = string.Format("http://wi.hm.edu/dozenten/{0}/index.de.html", dozent.Name.ToLowerInvariant()); } lecturer = new OrganiserMember { ShortName = dozent.DozentID, Name = dozent.Name, Role = dozent.Typ, Description = dozent.Name, UrlProfile = profileUrl, }; organiser.Members.Add(lecturer); db.Members.Add(lecturer); db.SaveChanges(); _numLecturers++; } return(lecturer); }
private bool HasChanged() { Person person = null; Person selectedPerson = (Person)lv_person.SelectedItem; if (selectedPerson != null) { Adresse adresse = new Adresse(tb_strasse.Text, tb_hausnummer.Text, tb_postleitzahl.Text, tb_ort.Text); Abschluss abschluss = new Abschluss(tb_abschluss.Text); switch (cb_rolle.SelectedItem) { case Rolle.Dozent: Dozent dozent = new Dozent(tb_vorname.Text, tb_nachname.Text, adresse, dp_geburtsdatum.Text, abschluss); person = dozent; break; case Rolle.Student: Student student = new Student(tb_vorname.Text, tb_nachname.Text, adresse, dp_geburtsdatum.Text, tb_matrikelnummer.Text, tb_ects.Text); person = student; break; } return(!person.Equals(selectedPerson)); } else { return(true); } }
public static DozentDTO toDTO(Dozent dozent) { return(new DozentDTO { EMail = dozent.EMail, Name = dozent.Name, Nummer = dozent.Nummer, }); }
public DozentViewModel() { currentDozent = new Dozent(); currentDozent.Key = "1234"; currentDozent.Vorname = "Raphael"; currentDozent.Nachname = "Heer"; currentDozent.Mail = "*****@*****.**"; currentDozent.Kuerzel = "her"; }
/// <summary> /// Deletes Dozent from database /// </summary> private void DeleteDozentExecute() { var deleteDozent = MessageBox.Show("Sind Sie sicher, dass Sie löschen möchten?", "Bestätigung", MessageBoxButton.YesNo, MessageBoxImage.Question); if (deleteDozent == MessageBoxResult.Yes) { Dozent deletedDozent = _dozentDB.DeleteDozent(CurrentDozent); DozentList.Remove(deletedDozent); } }
public Dozent DeleteDozent(Dozent dozent) { var delDozent = (from d in _db.Dozents where d.DozentId == dozent.DozentId select d).Single(); _db.Dozents.Remove(delDozent); _db.SaveChanges(); return(delDozent); }
public bool DozentExists(Dozent dozent) { var getdozent = from d in _db.Dozents where d.DozentNachname == dozent.DozentNachname && d.DozentVorname == dozent.DozentVorname && (d.AkadGrad == dozent.AkadGrad) select d; var dozentExists = getdozent.Any() ? true : false; return(dozentExists); }
/// <summary> /// Adds new dozent to Dozents table and ObservableCollection /// </summary> private void CreateDozent(Dozent dozent) { //Add new dozent to DB and retreive it Dozent DozentAdded = _dozentDB.CreateDozent(dozent); //Add new dozent to DozentList ObservableCollection DozentList.Add(DozentAdded); MessageBox.Show("Dozent wurde erfolgreich hinzufügt!", "Erfolg", MessageBoxButton.OK, MessageBoxImage.None); SelectedDozent = DozentAdded; }
private Kurs CreateCourse(Unterricht u, List <Raum> rooms, Dozent lecturer) { var fach = ctx.Faecher.SingleOrDefault(f => f.FachID.Equals(u.FachID)); if (fach != null) { fach.IsTouched = true; } var course = new Kurs { Id = u.UnterrichtID.ToString(), Fach = fach, }; course.Unterricht.Add(u); var group = ctx.Gruppen.SingleOrDefault(s => s.GruppenID.Equals(u.GruppeID)); if (group != null) { group.IsTouched = true; course.Gruppen.Add(group); } // Die LV var ce = new Termin() { VonStunde = u.Stunde, BisStunde = u.Stunde, Tag = u.Tag, }; foreach (var room in rooms) { ce.Raeume.Add(room); room.IsTouched = true; } if (lecturer != null) { ce.Dozenten.Add(lecturer); lecturer.IsTouched = true; } course.Termine.Add(ce); ctx.Kurse.Add(course); return(course); }
} //Command to cancel/close window #endregion #region Ctor // Initializes a new instance of the AddDozentViewModel class. public AddDozentViewModel() { try { Dozent = new Dozent(); // Command to Add Dozent details to Dozent DB AddCommand = new RelayCommand(AddDozent, CanAddDozent); CancelCommand = new RelayCommand(Cancel); Dozent.IsOkChanged += OnDozentPropertyChanged; } catch (Exception e) { throw e; } }
private void btn_save_Click(object sender, RoutedEventArgs e) { Person newPerson = null; Rolle rolle = (Rolle)cb_rolle.SelectedItem; string vorname = tb_vorname.Text; string nachname = tb_nachname.Text; string strasse = tb_strasse.Text; string hausnummer = tb_hausnummer.Text; string postleitzahl = tb_postleitzahl.Text; string ort = tb_ort.Text; Adresse adresse = new Adresse(strasse, hausnummer, tb_postleitzahl.Text, tb_ort.Text); string geburtstag = dp_geburtsdatum.Text; Abschluss abschluss = new Abschluss(tb_abschluss.Text); string matrikelnummer = tb_matrikelnummer.Text; string ects = tb_ects.Text; switch (rolle) { case Rolle.Dozent: Dozent dozent = new Dozent(vorname, nachname, adresse, geburtstag, abschluss); newPerson = dozent; break; case Rolle.Student: Student student = new Student(vorname, nachname, adresse, geburtstag, matrikelnummer, ects); newPerson = student; break; } if (lv_person.SelectedItem is Person selectedPerson) { Person existingPerson = PersonListe.Instance.Where(x => x.Equals(selectedPerson)).Single(); existingPerson.Update(newPerson); lv_person.SelectedItem = newPerson; } else if (!IsDuplicate(newPerson)) { PersonListe.Instance.Add(newPerson); lv_person.SelectedItem = newPerson; } }
/// <summary> /// Checks if Dozent already exists in Dozents table /// </summary> private void CheckDozentExists(Dozent dozent) { bool DozentExists = _dozentDB.DozentExists(dozent); if (DozentExists) { var createDuplicate = MessageBox.Show("Dozent existiert bereits. Trotzdem hinzufügen?", "Bestätigung", MessageBoxButton.YesNo, MessageBoxImage.Question); if (createDuplicate == MessageBoxResult.Yes) { CreateDozent(dozent); } } else { CreateDozent(dozent); } Messenger.Default.Send(new NotificationMessage("CloseAddDozentView")); Cleanup(); }
private void Lv_person_SelectionChanged(object sender, SelectionChangedEventArgs e) { btn_reset.IsEnabled = false; btn_new.IsEnabled = true; btn_del.IsEnabled = true; btn_save.IsEnabled = false; if (lv_person.SelectedItem is Person selectedPerson) { dp_geburtsdatum.SelectedDate = selectedPerson.Geburtsdatum; tb_vorname.Text = selectedPerson.Vorname; tb_nachname.Text = selectedPerson.Nachname; tb_strasse.Text = selectedPerson.Adresse.Strasse; tb_hausnummer.Text = selectedPerson.Adresse.Hausnummer; tb_postleitzahl.Text = selectedPerson.Adresse.Postleitzahl.ToString(); tb_ort.Text = selectedPerson.Adresse.Ort; cb_rolle.SelectedItem = selectedPerson.Rolle; switch (selectedPerson.Rolle) { case Rolle.Dozent: Dozent dozent = (Dozent)selectedPerson; tb_abschluss.Text = dozent.Abschluss.Name; break; case Rolle.Student: Student student = (Student)selectedPerson; tb_matrikelnummer.Text = student.Matrikelnummer.ToString(); tb_ects.Text = student.ECTS.ToString(); break; } validationController.ResetValidAttributes(true); } else { validationController.ResetValidAttributes(false); } }
/// <summary> /// Saves updated Dozent to database /// </summary> private void SaveDozentExecute() { bool DozentExists = _dozentDB.DozentExists(CurrentDozent); if (DozentExists) { var createDuplicate = MessageBox.Show("Dozent existiert bereits. Trotzdem speichern?", "Bestätigung", MessageBoxButton.YesNo, MessageBoxImage.Question); if (createDuplicate == MessageBoxResult.Yes) { Dozent updatedDozent = _dozentDB.UpdateDozent(CurrentDozent); SelectedDozent = updatedDozent; } else { SelectedDozent.CopyTo(CurrentDozent); } } else { Dozent updatedDozent = _dozentDB.UpdateDozent(CurrentDozent); SelectedDozent = updatedDozent; } }
private void ReadGPU004(string fileName) { var lines = GetFileContent(fileName); var n = lines.Count(); foreach (var line in lines) { var words = line.Split(seperator); var GPU004DozID = words[0].Replace("\"", ""); var GPU004DozName = words[1].Replace("\"", ""); var GPU004DozTyp = words[22].Replace("\"", ""); var doz = new Dozent() { DozentID = GPU004DozID, Name = GPU004DozName, Typ = GPU004DozTyp, }; ctx.Dozenten.Add(doz); } }
public DozentViewModel() { currentDozent = new Dozent(); }