I have a range of days that I need to find out if a weekend is in this range. If so I add 2 days to the final range (Monday to Sunday, changes it to Monday to Wednesday. (based on the user selection number of days E.g 5)
I have made a way to parse the days (not sure if it's the best practice) & not sure how to continue. So far:
////TODO Refactor to new class
DateTime startingDate = DateTime.Parse("07/25/2018");//TODO Insert variable from poted form
DateTime endingDate = DateTime.Parse("07/08/2018");//TODO Insert variable from posted form
var days= Enumerable.Range(0, 1 + endingDate.Subtract(startingDate).Days)
.Select(offset => startingDate.AddDays(offset))
.ToList();
In my opinion, I need to do it like the following pseudo-code:
if day.contains dayOfWeek.Saturday ||Or dayofWeek.Friday {Add.Days(2)}
But I can't find out how to .