Exemplo n.º 1
0
        public bool IsInNotificationWindow(string startTimeConfigName, string endTimeConfigName)
        {
            var startTimeStr = _configRepository.Get <string>(startTimeConfigName);
            var endTimeStr   = _configRepository.Get <string>(endTimeConfigName);
            var startTime    = DateTimeOffset.Parse(startTimeStr);
            var endTime      = DateTimeOffset.Parse(endTimeStr).AddDays(1); //We need to add days - since the end time is in the morning (For example 8pm -> 4am).
            //Not adding the AddDays() would mean we're never in the time frame (after 8pm and before 4am on the same dame).
            var currentTime = _time.CurrentDateTimeOffset();

            return(currentTime > startTime && currentTime < endTime);
        }