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); }
public IEnumerable <Examination> Generate(ExaminationGeneratorDTO examinationDTO) { ICollection <Examination> examinations = new List <Examination>(); ICollection <Appointment> appointments = GenerateAppointments(examinationDTO.StartDate, examinationDTO.EndDate); foreach (Appointment app in appointments) { foreach (Room room in examinationDTO.Rooms) { Examination examination = new Examination(app, examinationDTO.Patient, examinationDTO.Doctor, room); if (examination.IsAvailable()) { examinations.Add(examination); } } } return(examinations); }