MealDetails GetNextMealReminder(ComputritionSettings settings, PatronInfo patron)
        {
            var now       = DateTime.Now;
            var nextCheck = now.AddMinutes(5);

            if (settings?.Reminders?.Count > 0)
            {
                foreach (ComputritionMeal compMeal in settings.Meals)
                {
                    var meal = patron.Meals?.Find((cMeal) => { return(cMeal.Code == compMeal.Code); });
                    if (meal == null)
                    {
                        break;
                    }
                    var endingTime = meal.EndTime;
                    if (settings.Reminders
                        .Select((reminder) => { return(endingTime.AddMinutes(-reminder)); })
                        .Where((notTime) => { return(notTime.CompareTo(nextCheck) <= 0 && notTime.CompareTo(now) > 0); })
                        .ToList().Count > 0)
                    {
                        return(new MealDetails(meal, compMeal));
                    }
                }
            }
            return(null);
        }
        public async Task RefreshSettings()
        {
            try
            {
                _settings = await GetSettings();

                refreshInterval = _settings.CheckInterval != 0 ? _settings.CheckInterval : 10;
                if (ComputritionMrn == null)
                {
                    _mrn = await GetMRN();
                }
                else
                {
                    _mrn = ComputritionMrn;
                }

                computrition = new ComputritionService(new HttpConnector(15000), _settings.ServerAddress);

                _patron = await GetPatronInfo();
            }
            catch (Exception ex)
            {
                _core.Logger.Error(this, "Unable to get settings: " + ex.Message);
                refreshInterval = 1;
            }
        }