You should definitely reorganize dropoffDate, because the code is duplicated 3 times! The simplest cleanup: I would introduce pickupDate validation function and another to test dropoffDate:
private bool IsPickupWeekend(DateTime pickupDate) { switch (pickupDate.DayOfWeek) { case DayOfWeek.Thursday: return pickupDate.Hour >= 12; case DayOfWeek.Friday: case DayOfWeek.Saturday: return true; } } return false; } private bool IsWeekendDropOff(DateTime dropoffDate) { switch (dropoffDate.DayOfWeek) { case DayOfWeek.Sunday: return true; case DayOfWeek.Monday: if (dropoffDate.Hour <= 12) { return true; } return false; } return false; }
And now your main function is 2 liners:
if (ts.TotalDays >= 2 && ts.TotalDays <= 4) { return IsPickupWeekend(pickupDate) && IsWeekendDropOff(dropoffDate); }
source share