public bool TestCheckAvailabilityForYearlyEvents(string currentDate, string dayOfYear, int weekdaySequence, int weekday, int month, int frequency, int option)
        {
            var service = new RecurrenceService();

            RecurrenceYearlyModel model;

            if (option == 1)
            {
                model = new RecurrenceYearlyModel
                {
                    StartDate  = DateTime.Parse("01/11/2016"),
                    EndDate    = DateTime.Parse("30/11/2017"),
                    DateOfYear = DateTime.Parse(dayOfYear), // date of year
                    NthWeekday = WeekdaySequences.None,
                    Weekday    = Weekdays.None,
                    Month      = Months.None,
                    NumOfYears = frequency // frequency
                };
            }
            else
            {
                model = new RecurrenceYearlyModel
                {
                    StartDate  = DateTime.Parse("01/11/2016"),
                    EndDate    = DateTime.Parse("30/11/2017"),
                    DateOfYear = DateTime.MinValue,
                    NthWeekday = (WeekdaySequences)weekdaySequence, // number of weekday
                    Weekday    = (Weekdays)weekday,                 // weekday
                    Month      = (Months)month,                     // month
                    NumOfYears = frequency                          // frequency
                };
            }

            return(service.CheckAvailability(DateTime.Parse(currentDate), model));
        }
        /// <summary>
        /// The check availability for yearly 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, RecurrenceYearlyModel recurringItem)
        {
            var newStartDate = recurringItem.StartDate;

            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.NumOfYears == 0)
                {
                    return(false);
                }

                if (recurringItem.DateOfYear != DateTime.MinValue)
                {
                    // spcified date recurring yearly.
                    return(currenDate.Month == recurringItem.DateOfYear.Month &&
                           currenDate.Day == recurringItem.DateOfYear.Day &&
                           (currenDate.Year - recurringItem.StartDate.Year) % recurringItem.NumOfYears == 0);
                }
                else
                {
                    // spcified the nth week and weekday of the month recurring yearly.
                    return(this.CheckNthWeekdayByMonth(recurringItem.Weekday, recurringItem.NthWeekday, currenDate) &&
                           currenDate.Month == (int)recurringItem.Month &&
                           (currenDate.Year - recurringItem.StartDate.Year) % recurringItem.NumOfYears == 0);
                }
            }

            return(false);
        }