public void CanCreateTimeSlotCollection() { var from = DateTime.Today.AddHours(12); var to = DateTime.Today.AddHours(16); var workday = new Workday("13:00", "16:00", SlotDuration.ThirtyMinutes); var collection = TimeSlotCollection.Create(from, to, workday); Assert.AreEqual(6, collection.Count); Assert.AreEqual(13, collection[0].StartTime.Hour, "Start time hour should be 16"); Assert.AreEqual(0, collection[0].StartTime.Minute, "Start time minute should be 0"); Assert.AreEqual(16, collection[collection.Count - 1].EndTime.Hour, "End time hour should be 16"); Assert.AreEqual(0, collection[collection.Count - 1].EndTime.Minute, "End time minute should be 0"); }
public TimeSlotCollection GetSlots(DateTime startDate, DateTime endDate, Workday workday) { startDate = startDate.Date; endDate = endDate.Date; var slots = TimeSlotCollection.Create(startDate, endDate, workday); //Get appointments between start and end date. var appointments = (from a in this.Session.Query <Appointment>() where a.StartTime >= startDate && a.EndTime <= endDate.AddDays(1) select a).ToList(); //Remove slots that are overlapping with aleady taken meetings var result = (from slot in slots where IsNotOverlapping(appointments, slot) select slot); return(TimeSlotCollection.Create(result)); }