Exemplo n.º 1
0
 /// <summary>
 /// Gets the number of weekdays between 2 date excluding public holidays.
 /// </summary>
 /// <param name="from"></param>
 /// <param name="to"></param>
 /// <returns></returns>
 public int GetWeekDays(DateTime from, DateTime to)
 {
     var dayDifference = (int)to.Subtract(from).TotalDays - 1;
     List<PublicHoliday> publicHolidays = publicHolidayProvider.GetPublicHolidays(from, to);
     return Enumerable
         .Range(1, dayDifference)
         .Select(x => from.AddDays(x))
         .Count(x => x.DayOfWeek != DayOfWeek.Saturday && x.DayOfWeek != DayOfWeek.Sunday 
         && publicHolidays!=null && !publicHolidays.Exists(p=> p.HolidayDate == x.Date));
 }
Exemplo n.º 2
0
        public object Get()
        {
            List <PublicHoliday> publicHolidays = _publicHolidayProvider.GetPublicHolidays(DateTime.Now.Year);

            return(new
            {
                Message = "List of public holidays",
                PublicHolidays = publicHolidays
            });
        }