private void ScheduleEmergencyAppointmentButton_Click(object sender, RoutedEventArgs e) { int patientCardId = ((PatientBasicDTO)AppointmentSearchPatientComboBox.SelectedItem).PatientCardId; int doctorSpecialtyId = ((SpecialtyDTO)AppointmentDoctorSpecializationComboBox.SelectedItem).Id; List <int> appointmentRequiredEquipmentTypes = new List <int>(); foreach (EquipmentTypeForViewDTO equipmentType in AllEquipmentTypes) { if (equipmentType.IsSelected) { appointmentRequiredEquipmentTypes.Add(equipmentType.EquipmentType.Id); } } AppointmentSearchWithPrioritiesDTO appointmentSearchParametersDTO = new AppointmentSearchWithPrioritiesDTO { InitialParameters = new BasicAppointmentSearchDTO(patientCardId, doctorJmbg: "0909965768767", appointmentRequiredEquipmentTypes, earliestDateTime: new DateTime(DateTime.Now.Year, DateTime.Now.Month, 29, 7, 0, 0, DateTimeKind.Utc), latestDateTime: new DateTime()), Priority = SearchPriority.Date, SpecialtyId = doctorSpecialtyId }; AppointmentService appointmentService = new AppointmentService(); if (EmergencyAppointmentSearchResultsDataGrid.SelectedItem == null) { List <EmergencyExaminationDTO> emergencyExaminationSearchResults = appointmentService.GetEmergencyAppointments(appointmentSearchParametersDTO); if (emergencyExaminationSearchResults.Count == 1 && emergencyExaminationSearchResults[0].UnchangedExamination.DateTime.Equals(emergencyExaminationSearchResults[0].ShiftedExamination.DateTime)) { appointmentService.AddExamination(emergencyExaminationSearchResults[0].UnchangedExamination, appointmentRequiredEquipmentTypes); InfoDialog infoDialog = new InfoDialog(String.Format("Uspešno ste zakazali pregled!{0}{0}Nakon zatvaranja ovog dijaloga, biće prikazano više informacija o zakazanom pregledu.", Environment.NewLine)); infoDialog.ShowDialog(); ShowDialogWithMoreDetailsAboutScheduledExamination(emergencyExaminationSearchResults[0].UnchangedExamination); ClearAppointmentSearchFields(); AppointmentSearchScrollViewer.ScrollToTop(); } else { EmergencyAppointmentSearchResultsDataGrid.ItemsSource = emergencyExaminationSearchResults; InfoDialog infoDialog = new InfoDialog("Nažalost u skorijem periodu nema slobodnih termina koji odgovaraju unetim parametrima. Možete pomeriti neki od postojećih termina. Termini su sortirani u tabeli po pogodnosti za pomeranje. Termin koji je najpogodniji za pomeranje je posebno naglašen."); infoDialog.ShowDialog(); } } else { EmergencyExaminationDTO selectedEmergencyExamination = (EmergencyExaminationDTO)EmergencyAppointmentSearchResultsDataGrid.SelectedItem; ExaminationDTO unchangedExamination = selectedEmergencyExamination.UnchangedExamination; ExaminationDTO examinationForScheduleDTO = new ExaminationDTO(unchangedExamination.DateTime, unchangedExamination.Doctor, unchangedExamination.RoomId, patientCardId); RescheduleExaminationDTO rescheduleExaminationDTO = new RescheduleExaminationDTO(examinationForScheduleDTO, selectedEmergencyExamination.UnchangedExamination, selectedEmergencyExamination.ShiftedExamination); appointmentService.RescheduleExamination(rescheduleExaminationDTO); InfoDialog infoDialog = new InfoDialog(String.Format("Uspešno ste zakazali pregled!{0}{0}Nakon zatvaranja ovog dijaloga, biće prikazano više informacija o zakazanom pregledu.", Environment.NewLine)); infoDialog.ShowDialog(); ShowDialogWithMoreDetailsAboutScheduledExamination(examinationForScheduleDTO); ClearAppointmentSearchFields(); AppointmentSearchScrollViewer.ScrollToTop(); } }