예제 #1
0
        public void Add(Appointment a)
        {
            /*SORTS AND ADDS APPOINTMENT BY STARTTIME*/
            int index = 0;

            if (appointments.Count() == 0)
            {
                this.appointments.Add(a);
            }
            else if (appointments.Count() == 1)
            {
                if (DateTime.Compare(a.GetStartTime(), appointments.GetAppointments()[index].GetStartTime()) < 0)
                {
                    this.appointments.Insert(index, a);
                }
                else
                {
                    this.appointments.Add(a);
                }
            }
            else if (appointments.Count() > 1)
            {
                int count = appointments.Count();

                while (index < count)
                {
                    if (DateTime.Compare(a.GetStartTime(), appointments.GetAppointments()[index].GetStartTime()) < 0)
                    {
                        appointments.Insert(index, a);
                        break;
                    }
                    else if (DateTime.Compare(a.GetStartTime(), appointments.GetAppointments()[appointments.Count() - 1].GetStartTime()) > 0)
                    {
                        appointments.Add(a);
                        break;
                    }
                    else if (DateTime.Compare(a.GetStartTime(), appointments.GetAppointments()[index].GetStartTime()) > 0)
                    {
                        if (DateTime.Compare(a.GetStartTime(), appointments.GetAppointments()[index + 1].GetStartTime()) < 0)
                        {
                            appointments.Insert(index + 1, a);
                            break;
                        }
                        else
                        {
                            index++;
                        }
                    }
                }
            }

            this.Notify();
        }
예제 #2
0
        public AppointmentList GetAppointments(List <String> doctors, List <DateTime> dates, Boolean availableOnly)
        {
            DateTime        curDate;
            AppointmentList filteredAppointments = new AppointmentList();
            AppointmentList appointments         = ((AppointmentModel)this.model).GetAppointments();

            if (!availableOnly)
            {
                if (dates.Count == 1)
                {
                    curDate = dates[0].Date;

                    foreach (Appointment t in appointments.GetAppointments())
                    {
                        if ((DateTime.Compare(t.GetStartTime().Date, curDate.Date) == 0))
                        {
                            foreach (String dr in doctors)
                            {
                                if (t.GetTitle().Equals(dr))
                                {
                                    filteredAppointments.Add(t);
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (Appointment t in appointments.GetAppointments())
                    {
                        if (t.GetStartTime().Date >= dates[0].Date && t.GetStartTime().Date <= dates[1].Date)
                        {
                            foreach (String dr in doctors)
                            {
                                if (t.GetTitle().Equals(dr))
                                {
                                    filteredAppointments.Add(t);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (dates.Count == 1)
                {
                    curDate = dates[0].Date;

                    foreach (Appointment t in appointments.GetAppointments())
                    {
                        if (t.Available())
                        {
                            if ((DateTime.Compare(t.GetStartTime().Date, curDate.Date) == 0))
                            {
                                foreach (String dr in doctors)
                                {
                                    if (t.GetTitle().Equals(dr))
                                    {
                                        filteredAppointments.Add(t);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (Appointment t in appointments.GetAppointments())
                    {
                        if (t.Available())
                        {
                            if (t.GetStartTime().Date >= dates[0].Date && t.GetStartTime().Date <= dates[1].Date)
                            {
                                foreach (String dr in doctors)
                                {
                                    if (t.GetTitle().Equals(dr))
                                    {
                                        filteredAppointments.Add(t);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(filteredAppointments);
        }