private Appointment FindAnyOtherAppoitnemnt(PriorityParameters parameters) { DateTime startFrom = parameters.ChosenStartDate; List <Appointment> allAppointmentsInTimePeriod = new List <Appointment>(); while (startFrom.Date.CompareTo(parameters.ChosenEndDate.Date) < 0) { var appointmentsForDoctors = appointmentService.GetAvailableForDay(startFrom, TypeOfAppointment.examination, false); allAppointmentsInTimePeriod.AddRange(appointmentsForDoctors.Values); startFrom = startFrom.AddDays(1); } return(RecommendAnyOtherResults(allAppointmentsInTimePeriod, parameters)); }
public Appointment Recommend(PriorityParameters parameters) { DateTime startFrom = new DateTime(parameters.ChosenStartDate.Year, parameters.ChosenStartDate.Month, parameters.ChosenStartDate.Day, startWorkingHours, 0, 0); parameters.ChosenEndDate = new DateTime(parameters.ChosenEndDate.Year, parameters.ChosenEndDate.Month, parameters.ChosenEndDate.Day, endWorkingHours, 0, 0); List <Appointment> allAppointmentsInTimePeriod = new List <Appointment>(); while (startFrom.Date.CompareTo(parameters.ChosenEndDate) < 0) { var appointmentsForDoctors = appointmentService.GetAvailableForDayAndDoctor(startFrom, parameters.ChosenDoctor, TypeOfAppointment.examination, false); allAppointmentsInTimePeriod.AddRange(appointmentsForDoctors.Values); startFrom = startFrom.AddDays(1); } return(RecommendResults(allAppointmentsInTimePeriod, parameters)); }
private Appointment RecommendAfterDate(PriorityParameters parameters) { Appointment appointmentToRecommend = null; while (appointmentToRecommend != null) { DateTime startFrom = parameters.ChosenEndDate.Date.AddDays(1); List <Appointment> allAppointmentsInTimePeriod = new List <Appointment>(); var appointmentsForDoctors = appointmentService.GetAvailableForDayAndDoctor(startFrom, parameters.ChosenDoctor, TypeOfAppointment.examination, false); foreach (Appointment appointment in appointmentsForDoctors.Values) { appointmentToRecommend = appointment; break; } } return(appointmentToRecommend); }
public Appointment RecommendResults(List <Appointment> allAppointmentsInTimePeriod, PriorityParameters parameters) { foreach (Appointment appointment in allAppointmentsInTimePeriod) { Console.WriteLine(appointment.StartTime.ToString("dd.MM.yyyy. HH:mm:ss") + " " + appointment.EndTime.ToString("dd.MM.yyyy. HH:mm:ss")); } if (allAppointmentsInTimePeriod.Count > 0) { return(allAppointmentsInTimePeriod[rndGen.Next(0, allAppointmentsInTimePeriod.Count)]); } return(RecommendAfterDate(parameters)); }
private Appointment RecommendBest(List <Appointment> allAppointmentsInTimePeriod, PriorityParameters parameters) { DateTime minimumDate = parameters.ChosenEndDate.Date; Appointment bestAppointment = null; foreach (Appointment appointment in allAppointmentsInTimePeriod) { if (appointment.StartTime.CompareTo(minimumDate) < 0) { minimumDate = appointment.StartTime; bestAppointment = appointment; } } return(bestAppointment); }
public Appointment RecommendResults(List <Appointment> allAppointmentsInTimePeriod, PriorityParameters parameters) { if (allAppointmentsInTimePeriod.Count > 0) { return(RecommendBest(allAppointmentsInTimePeriod, parameters)); } return(FindAnyOtherAppoitnemnt(parameters)); }