private static void DisplayList(string title, ScheduleAppointmentList list) { #if console Console.WriteLine("*************" + title); foreach (ScheduleAppointment item in list) { Console.WriteLine(item); } #endif }
/// <summary> /// Returns a the subset of MasterList between the 2 dates. /// </summary> /// <param name="day">Date for the returned items.</param> /// <returns>Returns a the subset of MasterList.</returns> public override IScheduleAppointmentList GetScheduleForDay(DateTime day) { ScheduleAppointmentList list = new ScheduleAppointmentList(); day = day.Date; foreach (ScheduleAppointment item in this.MasterList) { //do not want anything that ends at 12AM on the day if (item.StartTime.Date == day || (item.EndTime.Date == day && item.EndTime > day)) { list.Add(item); } } //DisplayList(string.Format("*************day {0}", day), list); return(list); }
/// <summary> /// Returns a the subset of MasterList between the 2 dates. /// </summary> /// <param name="startDate">Starting date limit for the returned items.</param> /// <param name="endDate">Ending date limit for the returned items.</param> /// <returns>Returns a the subset of MasterList.</returns> public override IScheduleAppointmentList GetSchedule(DateTime startDate, DateTime endDate) { ScheduleAppointmentList list = new ScheduleAppointmentList(); DateTime start = startDate.Date; DateTime end = endDate.Date; foreach (ScheduleAppointment item in this.MasterList) { //item.EndTime.AddMinutes(-1) is to make sure an item that ends at //midnight is not shown on the next days calendar if ((item.StartTime.Date >= start && item.StartTime.Date <= end) || (item.EndTime.AddMinutes(-1).Date > start && item.EndTime.Date <= end)) { list.Add(item); } } list.SortStartTime(); //DisplayList(string.Format("************dates between {0} and {1}", startDate, endDate), list); return(list); }