コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public Appointment RecommendResults(List <Appointment> allAppointmentsInTimePeriod, PriorityParameters parameters)
 {
     if (allAppointmentsInTimePeriod.Count > 0)
     {
         return(RecommendBest(allAppointmentsInTimePeriod, parameters));
     }
     return(FindAnyOtherAppoitnemnt(parameters));
 }