public void Schedule(ScheduleExaminationDTO examinationDTO) { DateTime startTime = examinationDTO.StartTime.AddHours(-1); DateTime endTime = examinationDTO.StartTime.AddHours(1); Patient patient = _patientRepository.Get(examinationDTO.PatientJmbg, startTime, endTime); Doctor doctor = _doctorRepository.Get(examinationDTO.DoctorJmbg, startTime, endTime); Room room = _roomRepository.Get(examinationDTO.RoomId, startTime, endTime); Examination examination = new Examination(examinationDTO.StartTime, patient, doctor, room); if (!examination.IsAvailable()) { throw new ValidationException("Examination is not available."); } if (examination.IsBefore(_clock.GetTimeLimit())) { throw new ValidationException("The time limit for scheduling the examinaton has passed."); } _examinationRepository.Add(examination); }