static JobPage() { SystemNavigationManager.GetForCurrentView().BackRequested += (s, e) => { ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; localSettings.Values.Remove(Settings.JOBNAME); localSettings.Values.Remove(Settings.JOBCRON); using (var context = new TaskSchedulerDbContext()) { Func <Models.Action, bool> predicate = x => x.JobId == null; context.Actions.RemoveRange(context.ActionsForActionPredicate(predicate)); context.UriActions.RemoveRange(context.UriActionsForActionPredicate(predicate)); context.NotificationActions.RemoveRange(context.NotificationActionsForActionPredicate(predicate)); context.ApplicationActions.RemoveRange(context.ApplicationActionsForActionPredicate(predicate)); context.SaveChanges(); } }; }
private void AppBarButton_Delete(object sender, RoutedEventArgs e) { if ((int)localSettings.Values[Settings.JOBACTION] == Settings.Actions.CREATE) { return; } using (var context = new TaskSchedulerDbContext()) { Job job = context.Jobs.Where(x => x.Id == (int)localSettings.Values[Settings.JOBID]).First(); context.Actions.RemoveRange(context.ActionsForActionPredicate(predicate)); context.UriActions.RemoveRange(context.UriActionsForActionPredicate(predicate)); context.NotificationActions.RemoveRange(context.NotificationActionsForActionPredicate(predicate)); context.ApplicationActions.RemoveRange(context.ApplicationActionsForActionPredicate(predicate)); context.Jobs.Remove(job); context.SaveChanges(); } Frame.GoBack(); }