public static bool CanNavigateToPreviousWeek(DateTime current) { var minus1Week = current.AddDays(-7); var sunday = DateTimeUtility.GetSundayOfWeekFor(minus1Week); return(DateTime.Today.IsSmallerThanOrEqualAs(sunday)); }
public static bool CanNavigateToPreviousMonth(DateTime current) { var minus1Month = current.AddMonths(-1); var sunday = DateTimeUtility.GetSundayOfWeekFor(minus1Month); return(DateTime.Today.IsSmallerThanOrEqualAs(sunday)); }
public void SundayOfWeekTest() { var sunday = DateTimeUtility.GetSundayOfWeekFor(new DateTime(2017, 2, 8)); Assert.IsTrue(sunday.DayOfWeek == DayOfWeek.Sunday); Assert.IsTrue(sunday.Year == 2017); Assert.IsTrue(sunday.Month == 2); Assert.IsTrue(sunday.Day == 12); Assert.IsTrue(sunday.Hour == 0); Assert.IsTrue(sunday.Minute == 0); Assert.IsTrue(sunday.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)); }