Esempio n. 1
0
        private async void ExecuteDelete(DataUpdateJobDetailsViewModel vm)
        {
            if (vm == null)
            {
                throw new ArgumentNullException(nameof(vm));
            }

            var selectedJob = vm.Job;

            MessageDialogResult dialogResult = await DialogService.ShowMessageAsync(this,
                                                                                    "Delete Job",
                                                                                    string.Format("Are you sure you want to delete {0}?", selectedJob.Name),
                                                                                    MessageDialogStyle.AffirmativeAndNegative);

            if (dialogResult != MessageDialogResult.Affirmative)
            {
                return;
            }

            using (var context = new MyDBContext())
            {
                var job = context.DataUpdateJobs.FirstOrDefault(x => x.ID == selectedJob.ID);
                if (job == null)
                {
                    return;
                }

                context.DataUpdateJobs.Remove(job);

                context.SaveChanges();
            }

            Jobs.Remove(vm);
        }
Esempio n. 2
0
        private async void ExecuteDelete(DataUpdateJobDetailsViewModel vm)
        {
            if (vm == null) throw new ArgumentNullException(nameof(vm));

            var selectedJob = vm.Job;

            MessageDialogResult dialogResult = await DialogService.ShowMessageAsync(this,
                "Delete Job",
                string.Format("Are you sure you want to delete {0}?", selectedJob.Name),
                MessageDialogStyle.AffirmativeAndNegative);

            if (dialogResult != MessageDialogResult.Affirmative) return;

            using (var context = new MyDBContext())
            {
                var job = context.DataUpdateJobs.FirstOrDefault(x => x.ID == selectedJob.ID);
                if (job == null) return;

                context.DataUpdateJobs.Remove(job);

                context.SaveChanges();
            }

            Jobs.Remove(vm);
        }