public bool TestCheckAvailabilityForMonthlyEvents(string currentDate, int dayOfMonth, int weekdaySequence, int weekday, int frequency, int option)
        {
            var service = new RecurrenceService();

            RecurrenceMonthlyModel model;

            if (option == 1)
            {
                // Option 1
                model = new RecurrenceMonthlyModel
                {
                    StartDate   = DateTime.Parse("01/11/2016"),
                    EndDate     = DateTime.Parse("30/11/2017"),
                    DateOfMoth  = dayOfMonth,                // day of month
                    NthWeekday  = 0,
                    Weekday     = Weekdays.None,
                    NumOfMonths = frequency,                 // frequency
                };
            }
            else
            {
                // Option 2
                model = new RecurrenceMonthlyModel
                {
                    StartDate   = DateTime.Parse("01/11/2016"),
                    EndDate     = DateTime.Parse("30/11/2017"),
                    DateOfMoth  = 0,
                    NthWeekday  = (WeekdaySequences)weekdaySequence, // number of weekday
                    Weekday     = (Weekdays)weekday,                 // weekday
                    NumOfMonths = frequency                          // frequency
                };
            }

            return(service.CheckAvailability(DateTime.Parse(currentDate), model));
        }
        /// <summary>
        /// The check availability for monthly 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, RecurrenceMonthlyModel 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.NumOfMonths == 0)
                {
                    return(false);
                }

                if (recurringItem.DateOfMoth > 0)
                {
                    // specified recurring day of the month. i.e. 18th of the month.
                    return(currenDate.Day == recurringItem.DateOfMoth &&
                           Math.Abs(currenDate.Month - recurringItem.StartDate.Month) % recurringItem.NumOfMonths
                           == 0);
                }
                else
                {
                    // spcified the nth week and weekday that the event will happen. i.e. every first monday every month.
                    return(this.CheckNthWeekdayByMonth(recurringItem.Weekday, recurringItem.NthWeekday, currenDate) &&
                           Math.Abs(currenDate.Month - recurringItem.StartDate.Month) % recurringItem.NumOfMonths
                           == 0);
                }
            }

            return(false);
        }