コード例 #1
0
        private void UpdateEvents()
        {
            // Set Context
            _db = new Context();

            // Load Sounds
            Sound.ItemsSource = Model.Sound.Fetch(_db);

            // Return if no date selected
            if (Calendar.SelectedDate == null)
            {
                return;
            }

            // Make Day if it doesn't exist
            var date = (DateTime)Calendar.SelectedDate;

            Day.AddIfNotExists(date);

            // Find the Day
            _day = _db.Days.FirstOrDefault(o => o.Date.Equals(date));
            if (_day == null)
            {
                App.ErrorMessage($"Could not find day with date {date.ToShortDateString()} in database.");
                return;
            }

            // Change window title
            Title = $"Edit Schedule {_day.Date.ToShortDateString()}";

            // Load Day Events from database
            _db.Entry(_day).Collection(o => o.Events).Query().OrderBy(o => o.Time).Load();
            _eventViewSource.Source = _db.Events.Local.ToObservableCollection();
        }