public int GetSlotsAmount(IDayWorkingHours dayWorkingHours)
 {
     List<ITimeSlot> timeSlots = dayWorkingHours.GetWorkingHours();
     Time minTime = timeSlots.Min(ts => ts.StartTime);
     Time maxTime = timeSlots.Max(ts => ts.StartTime.Add( ts.Duration ) );
     return GetSlotsAmount(minTime.GetAbsoluteDifference(maxTime));
 }
        private readonly int timeSlotDurationMinute = 15; //min

        #endregion Fields

        #region Constructors

        public DayAgendaService(DateTime date, IDayWorkingHours wh,List<Booking> bookings = null  )
        {
            Date = date.Date;
            TimeSlots = CreateTimeSlots(wh,timeSlotDurationMinute);

            if (bookings != null)
            {
                Bookings = bookings;
                UpdateTimeSlots(bookings);
            }
            else
            {
                Bookings = new List<Booking>();
            }
        }
        private List<ITimeSlot> CreateTimeSlots(IDayWorkingHours dayWorkingHours,int slotDurationInMin)
        {
            List<ITimeSlot> timeSlots = new List<ITimeSlot>();
            List<ITimeSlot> whTimeSlots = dayWorkingHours.GetWorkingHours();
            whTimeSlots.Sort((ts1, ts2) => ts1.StartTime.CompareTo(ts2.StartTime));

            Time firstSlotTime = whTimeSlots[0].StartTime;
            TimeSpan timeSlotDuration = new TimeSpan(0,slotDurationInMin,0);

            ITimeSlot slot = new TimeSlot(1,firstSlotTime,timeSlotDuration,true);  // first timeslot
            int amountOfTimeSlots = slot.GetSlotsAmount(dayWorkingHours.GetWorkDayDuration());
            if (amountOfTimeSlots > 0)
            {
                timeSlots.Add(slot);
                for (int i = 1; i < amountOfTimeSlots; i++)
                {
                    Time nextSlotTime = slot.StartTime.Add(slot.Duration);
                    if (whTimeSlots.Any(ts=> ts.StartTime <= nextSlotTime
                                        && nextSlotTime < ts.StartTime.Add(ts.Duration)))
                    {
                        slot = new TimeSlot(i + 1, slot.StartTime.Add(slot.Duration), timeSlotDuration, true);
                    }
                    else
                    {
                        slot = new TimeSlot(i + 1, slot.StartTime.Add(slot.Duration), timeSlotDuration, false);
                    }
                    timeSlots.Add(slot);

                }
            }
            return timeSlots;
        }