public DateTimeOffset?UseRates(RateDefinitions rateSetInput)
        {
            var rates = new RateDateRange[MinutesInAWeek];

            var rateDateRanges = rateSetInput.BuildRateDateRanges();

            foreach (var rateDateRange in rateDateRanges)
            {
                var start = DayOfWeekToTimespansWithThatDuration[rateDateRange.DayOfWeek] + rateDateRange.Start;
                var end   = DayOfWeekToTimespansWithThatDuration[rateDateRange.DayOfWeek] + rateDateRange.End;

                for (int i = (int)start.TotalMinutes; i < (int)end.TotalMinutes; i++)
                {
                    if (rates[i] != null)
                    {
                        // If we're visiting a minute we've already processed, there's overlap in the rate definitions.
                        // Return null to indicate the rates are not valid.
                        return(null);
                    }
                    rates[i] = rateDateRange;
                }
            }

            _rates = rates;
            return(DateTimeOffset.UtcNow);
        }
        public DateTimeOffset?UseRates(RateDefinitions rateSetInput)
        {
            var rateDateRanges = rateSetInput
                                 .BuildRateDateRanges()
                                 .GroupBy(x => x.DayOfWeek)
                                 .ToDictionary(x => x.Key, y => y.OrderBy(x => x.Start).ToList());

            DateTimeOffset?timeRatesChanged = null;

            if (AreDateRangesValid(rateDateRanges))
            {
                _rateDateRangesByDayOfWeek = rateDateRanges;
                timeRatesChanged           = DateTimeOffset.UtcNow;
            }

            return(timeRatesChanged);
        }