namespace BMA.EHR.Recurit.Exam.Service.Core
{
    public static class HolidayHelper
    {
        public static bool IsHoliday(DateTime date, List<DateTime> holidays)
        {
            return holidays.Contains(date);
        }

        public static bool IsWeekend(DateTime date)
        {
            return date.DayOfWeek == DayOfWeek.Saturday
                || date.DayOfWeek == DayOfWeek.Sunday;
        }

        public static bool IsWeekend6Days(DateTime date)
        {
            return date.DayOfWeek == DayOfWeek.Sunday;
        }

        public static DateTime GetNextWorkingDay(DateTime date, List<DateTime> holidays)
        {
            do
            {
                date = date.AddDays(1);
            } while (IsHoliday(date, holidays) || IsWeekend(date));
            return date;
        }

        public static DateTime GetNextWorkingDay6Days(DateTime date, List<DateTime> holidays)
        {
            do
            {
                date = date.AddDays(1);
            } while (IsHoliday(date, holidays) || IsWeekend6Days(date));
            return date;
        }
    }
}
