public AppointmentDTO GetSuggestedAppointment(SuggestedAppointmentDTO suggestedAppointmentDTO) { DateTime currentDate = suggestedAppointmentDTO.DateStart; while (!currentDate.Equals(suggestedAppointmentDTO.DateEnd)) { AppointmentDTO appointment = new AppointmentDTO(); appointment.Date = currentDate; appointment.Physitian = suggestedAppointmentDTO.Physitian; appointment.Patient = suggestedAppointmentDTO.Patient; List <AppointmentDTO> suggestedAppointmentDTOs = GetAvailableAppointments(appointment); if (suggestedAppointmentDTOs.Count != 0) { return(suggestedAppointmentDTOs[0]); } currentDate = currentDate.AddDays(1); } if (suggestedAppointmentDTO.Prior) { DatePriorityStrategy datePriorityStrategy = new DatePriorityStrategy(); List <AppointmentDTO> suggestedAppointmentDTOsDate = datePriorityStrategy.FindSuggestedAppointments(suggestedAppointmentDTO); foreach (AppointmentDTO appointmentDTO in suggestedAppointmentDTOsDate) { List <AppointmentDTO> suggestedAppointmentDTOs = GetAvailableAppointments(appointmentDTO); if (suggestedAppointmentDTOs.Count != 0) { return(suggestedAppointmentDTOs[0]); } } } else { PhysitianPriorityStrategy physitianPriorityStrategy = new PhysitianPriorityStrategy(); List <AppointmentDTO> suggestedAppointmentDTOsPhysitian = physitianPriorityStrategy.FindSuggestedAppointments(suggestedAppointmentDTO); foreach (AppointmentDTO appointmentDTO in suggestedAppointmentDTOsPhysitian) { List <AppointmentDTO> suggestedAppointmentDTOs = GetAvailableAppointments(appointmentDTO); if (suggestedAppointmentDTOs.Count != 0) { return(suggestedAppointmentDTOs[0]); } } } return(null); }
public List <AppointmentDTO> FindSuggestedAppointments(SuggestedAppointmentDTO suggestedAppointmentDTO) { PhysitianFileSystem pfs = new PhysitianFileSystem(); List <Physitian> physitians = pfs.GetAll(); List <AppointmentDTO> appointmentDTOs = new List <AppointmentDTO>(); foreach (Physitian physitian in physitians) { DateTime currentDate = suggestedAppointmentDTO.DateStart; while (!currentDate.Equals(suggestedAppointmentDTO.DateEnd)) { AppointmentDTO appointment = new AppointmentDTO(); appointment.Date = currentDate; appointment.Physitian = physitian; appointment.Patient = suggestedAppointmentDTO.Patient; appointmentDTOs.Add(appointment); currentDate = currentDate.AddDays(1); } } return(appointmentDTOs); }
public List <AppointmentDTO> FindSuggestedAppointments(SuggestedAppointmentDTO suggestedAppointmentDTO) { DateTime currentDate = suggestedAppointmentDTO.DateStart.AddDays(-3); List <AppointmentDTO> appointmentDTOs = new List <AppointmentDTO>(); while (!currentDate.Equals(suggestedAppointmentDTO.DateEnd.AddDays(3))) { AppointmentDTO appointment = new AppointmentDTO(); if (currentDate.CompareTo(DateTime.Today) < 0) { continue; } appointment.Date = currentDate; appointment.Physitian = suggestedAppointmentDTO.Physitian; appointment.Patient = suggestedAppointmentDTO.Patient; appointmentDTOs.Add(appointment); currentDate = currentDate.AddDays(1); if (currentDate == suggestedAppointmentDTO.DateStart) { currentDate = suggestedAppointmentDTO.DateEnd; } } return(appointmentDTOs); }