private List <WorkHour> getListOfScheduledHours(List <Schedule> schedules, WorkDay day) { var listOfHoursScheduled = new List <WorkHour>(); foreach (var schedule in schedules) { if (schedule.StartDate.Day == day.GetDay() && schedule.StartDate.Month == day.GetMonth()) { DateTime dateFlag = schedule.EndDate; while (dateFlag > schedule.StartDate) { dateFlag = dateFlag.Subtract(TimeSpan.FromMinutes(15)); listOfHoursScheduled.Add(new WorkHour(dateFlag.Hour, dateFlag.Minute)); } } } return(listOfHoursScheduled); }