コード例 #1
0
        public List <DoctorAppointment> GenerateSchedule(DateTime startTime, DateTime endTime)
        {
            List <DoctorAppointment> doctorAppointments = new List <DoctorAppointment>();
            DateTime currentTime = startTime;
            int      i           = 1;

            while (currentTime < endTime)
            {
                DateTime          currentEndTime = currentTime.Add(new TimeSpan(0, 30, 0));
                DoctorAppointment appointment    = new DoctorAppointment
                {
                    Name      = "Slot" + i,
                    StartTime = currentTime,
                    EndTime   = currentEndTime
                };
                doctorAppointments.Add(appointment);
                currentTime = currentEndTime.Add(new TimeSpan(0, 15, 0));
                i++;
            }
            return(doctorAppointments);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: tarikulcse2/selise-task
        static List <DoctorAppointment> GetInput()
        {
            List <DoctorAppointment> doctorAppointments = new List <DoctorAppointment>();
            DoctorAppointment        input1             = new DoctorAppointment
            {
                Name      = "Slot 1",
                StartTime = DateTime.Now.Date.Add(new TimeSpan(9, 0, 0)),
                EndTime   = DateTime.Now.Date.Add(new TimeSpan(9, 30, 0))
            };

            DoctorAppointment input2 = new DoctorAppointment
            {
                Name      = "Slot 2",
                StartTime = DateTime.Now.Date.Add(new TimeSpan(9, 45, 0)),
                EndTime   = DateTime.Now.Date.Add(new TimeSpan(10, 15, 0))
            };

            doctorAppointments.Add(input1);
            doctorAppointments.Add(input2);
            return(doctorAppointments);
        }
コード例 #3
0
 private bool CheckedBookedSlot(List <DoctorAppointment> list, DoctorAppointment doctorAppointment)
 {
     return(list.FindAll(r => r.StartTime == doctorAppointment.StartTime && r.EndTime == doctorAppointment.EndTime).Count > 0);
 }