Exemplo n.º 1
0
        private bool StatusCheck()
        {
            // Set Context
            _db = new Context();

            // Get today's date
            var dateToCheck = Day.Today();

            for (var i = 0; i < App.AdvanceSchedule; i++)
            {
                // Find the Day
                var day = _db.Days.Include(o => o.Events).FirstOrDefault(o => o.Date.Equals(dateToCheck));
                if (day == null)
                {
                    return(false);
                }

                // Check if any Events
                if (day.Events.Count < 1)
                {
                    return(false);
                }

                // Increment the date
                dateToCheck = dateToCheck.AddDays(1);
            }

            // Check was good
            return(true);
        }
Exemplo n.º 2
0
        public void UpdateEvents()
        {
            // Set Context
            _db = new Context();

            // Load Sounds
            UpdateSounds();

            // Get today's date
            var today = Day.Today();

            // Add if needed
            Day.AddIfNotExists(today);

            // Find the Day
            var day = _db.Days.FirstOrDefault(o => o.Date.Equals(today));

            if (day == null)
            {
                App.ErrorMessage($"Could not find day with date {today.ToShortDateString()} in database.");
                return;
            }

            // Load Events
            _db.Entry(day).Collection(o => o.Events).Query().OrderBy(o => o.Time).Load();
            _eventViewSource.Source = _db.Events.Local.ToObservableCollection();

            // Update status
            if (StatusCheck())
            {
                StatusText.Text       = "Schedule is Good";
                StatusText.Foreground = new BrushConverter().ConvertFromString("Green") as SolidColorBrush;
            }
            else
            {
                StatusText.Text       = $"WARNING: Schedule should be completed {App.AdvanceSchedule} days in advance";
                StatusText.Foreground = new BrushConverter().ConvertFromString("Red") as SolidColorBrush;
            }
        }