I am fairly new into asp.net MVC c# I am working on request holiday app where an employee can request holidays. The problem is the app works fine, however, I am trying to set 8 hours a day when an employee requests a holiday I have scratching my head from 2 days already seen every topic in StackOverflow and here and still can't get to work if anyone has any suggestions it will be much appreciated. Here is a snippet of the calculation of the working days excluding weekends. Thank you in advance.
public static class DateHelpers
{
public static int DaysBetweenExcludingWeekends(DateTime startDate, DateTime endDate)
{
var days = 0;
while (startDate <= endDate)
{
if (startDate.DayOfWeek != DayOfWeek.Saturday && startDate.DayOfWeek != DayOfWeek.Sunday)
{
days++;
}
startDate = startDate.AddDays(1);
}
return days;
}
}