Beispiel #1
0
 public void UpdateReminder()
 {
     using (var context = new ReminderContext())
     {
         NotificationList.ItemsSource = context.Reminders
                                        .OrderByDescending(x => x.CreateTime).ToList();
     }
 }
Beispiel #2
0
        // Удалить
        private void DeleteButtonClick(object sender, RoutedEventArgs e)
        {
            if (NotificationList.SelectedIndex == -1)
            {
                return;
            }

            Reminder notificationToDelete = NotificationList.Items[NotificationList.SelectedIndex] as Reminder;

            using (var context = new ReminderContext())
            {
                context.Entry(notificationToDelete).State = System.Data.Entity.EntityState.Deleted;
                context.SaveChanges();
            }

            UpdateReminder();
        }
Beispiel #3
0
 public void UpdateTimers(Reminder reminder = null)
 {
     if (reminder == null)
     {
         using (var context = new ReminderContext())
         {
             foreach (var ntf in context.Reminders.Where(n => n.NotifyTime > DateTime.Now))
             {
                 Timers.Add(new Timer(new TimerCallback(Notify), ntf.NotificationText,
                                      GetMilliseconds(ntf.NotifyTime), Timeout.Infinite));
             }
         }
     }
     else
     {
         Timers.Add(new Timer(new TimerCallback(Notify), reminder.NotificationText,
                              GetMilliseconds(reminder.NotifyTime), Timeout.Infinite));
     }
 }