private void Button_confirm_creation(object sender, RoutedEventArgs e) { // IF SELECTED ITEM IS NULL THEN ADD IT TO SPEAKER Speaker speaker = (Speaker)newSpeakerComboBox.SelectedItem; TimeSlot timeSlot = (TimeSlot)newTimeslotComboBox.SelectedItem; Room room = (Room)newRoomComboBox.SelectedItem; Console.WriteLine(newSpeakerComboBox.Text); Session newSession = new Session(); newSession.Room = room.Id; newSession.Room_1 = room.Name; if (speaker != null) { newSession.Speaker = speaker.Id; newSession.Speaker_1 = speaker.Name; } else { newSession.Speaker_1 = newSpeakerComboBox.Text; Speaker newSpeaker = new Speaker(newSpeakerComboBox.Text); SpeakerDatabaseManager sp = new SpeakerDatabaseManager(); sp.addSpeaker(newSpeaker); List <Speaker> allSps = new List <Speaker>(sp.retrieveSpeakers()); foreach (Speaker i in allSps) { if (i.Name.Equals(newSession.Speaker_1)) { newSession.Speaker = i.Id; } } } newSession.TimeSlots = timeSlot.Id; newSession.Timeslot_1 = timeSlot.ConcatTimeSlot; newSession.Title = newTitleTextBox.Text; newSession.Date = newDate.Text; if (sessionViewModel.checkIfExists(newSession)) { MessageBox.Show("This Room is taken on this timeslot and Date"); return; } AttendanceDatabaseManager ad = new AttendanceDatabaseManager(); Attendance attendance = new Attendance(); sessionViewModel.creatingSessions(newSession); SessionsDatabaseManager sd = new SessionsDatabaseManager(); foreach (Session s in sd.getSessions()) { if (newSession.TimeSlots == s.TimeSlots && newSession.Speaker == s.Speaker) { Console.WriteLine("NAME" + s.Speaker_1); attendance.Session_id = s.Id; } } Console.WriteLine("aa " + attendance.Session_id); attendance.Count_beg = 0; attendance.Count_mid = 0; attendance.Count_end = 0; ad.addCount(attendance); // timeslot // speaker // title // date // room createDialogHost.IsOpen = false; }