/// <summary> /// The check availability for daily events. /// </summary> /// <param name="currenDate"> /// The date. /// </param> /// <param name="recurringItem"> /// The recurring item. /// </param> /// <returns> /// Check whether or not the event is available on the given date. /// </returns> public bool CheckAvailability(DateTime currenDate, RecurrenceDailyModel recurringItem) { int result1 = DateTime.Compare(currenDate, recurringItem.StartDate); int result2 = DateTime.Compare(currenDate, recurringItem.EndDate); if (result1 >= 0 && result2 <= 0) { // frequency can't be empty/0 if (recurringItem.Days == 0) { return(false); } if (recurringItem.Days == 1) { return(true); } if ((currenDate - recurringItem.StartDate).Days % recurringItem.Days != 0) { return(false); } } return(true); }
public bool TestCheckAvailabilityForDailyEvents(string currentDate, int frequency) { var service = new RecurrenceService(); // recur every day. var model = new RecurrenceDailyModel { StartDate = DateTime.Parse("01/11/2016"), EndDate = DateTime.Parse("31/01/2017"), Days = frequency }; return(service.CheckAvailability(DateTime.Parse(currentDate), model)); }