public void MondayOfWeekTest()
        {
            var monday = DateTimeUtility.GetMondayOfWeekFor(new DateTime(2017, 2, 8));

            Assert.IsTrue(monday.DayOfWeek == DayOfWeek.Monday);
            Assert.IsTrue(monday.Year == 2017);
            Assert.IsTrue(monday.Month == 2);
            Assert.IsTrue(monday.Day == 6);
            Assert.IsTrue(monday.Hour == 0);
            Assert.IsTrue(monday.Minute == 0);
            Assert.IsTrue(monday.Second == 0);
        }
        public static IList <BookingDate> CalculateBookingDates(DateTime date, int eventId)
        {
            Scheduler scheduler;

            var bookingTimeOverrideRules = Database.Instance.GetRules().OfType <BookingTimeOverrideRule>().Where(r => r.EventId == eventId);

            if (bookingTimeOverrideRules.Any())
            {
                var timeProvider = new BookingTimeOverrideTimeProvider(bookingTimeOverrideRules);
                scheduler = new Scheduler(Database.Instance, Database.Instance, timeProvider);
            }
            else
            {
                scheduler = Scheduler.CreateNew(Database.Instance);
            }

            var @event = Database.Instance.GetEventBy(eventId);
            var monday = DateTimeUtility.GetMondayOfWeekFor(date);
            var sunday = DateTimeUtility.GetSundayOfWeekFor(date);

            return(scheduler.GetBookingDateRange(monday, sunday, @event));
        }