Ejemplo n.º 1
0
        private static int getBusinessDaysCount(DateTime startDate, DateTime endDate, OperationCountry operationCountry)
        {
            if (endDate < startDate)
            {
                throw new ArgumentOutOfRangeException(nameof(startDate));
            }

            var weekDays = operationCountry.WeekDays;
            var holidays = operationCountry.Holidays.Select(s => s.HolidayDate).ToArray();

            var allDates = Enumerable.Range(0, 1 + (endDate - startDate).Days)
                           .Select(count => startDate.AddDays(count)).ToArray();

            var countOfBusinesDays = allDates
                                     .Where(x => !weekDays.Contains(x.DayOfWeek) && !holidays.Contains(x))
                                     .Count();

            return(countOfBusinesDays);
        }
Ejemplo n.º 2
0
        public static double GetLateFeeCalculate(DateTime startDate, DateTime endDate, OperationCountry operationCountry)
        {
            var businessDaysCount = getBusinessDaysCount(startDate, endDate, operationCountry);

            return(operationCountry.LateFees * businessDaysCount);
        }