Beispiel #1
0
        private void SaveProcessingType(object processingTypeInstance)
        {
            ProcessingTypeViewModel processingTypeViewModel = processingTypeInstance as ProcessingTypeViewModel;

            if (processingTypeViewModel.ProcessingType != null)
            {
                if (!processingTypeViewModel.IsValid)
                {
                    Application.Current.MainPage.DisplayAlert("Предупреждение", "Задайте название вида обработки", "Ok");
                    return;
                }

                using (AppDbContext db = App.GetContext())
                {
                    if (processingTypeViewModel.ProcessingType.ProcessingTypeId == 0)
                    {
                        db.Entry(processingTypeViewModel.ProcessingType).State = EntityState.Added;
                    }
                    else
                    {
                        db.ProcessingTypes.Update(processingTypeViewModel.ProcessingType);
                    }
                    db.SaveChanges();
                }
            }
            Back();
        }
Beispiel #2
0
        private void DeleteProcessingType(object processingTypeInstance)
        {
            ProcessingTypeViewModel processingTypeViewModel = processingTypeInstance as ProcessingTypeViewModel;

            if (processingTypeViewModel.ProcessingType != null && processingTypeViewModel.ProcessingType.ProcessingTypeId != 0)
            {
                using (AppDbContext db = App.GetContext())
                {
                    db.ProcessingTypes.Remove(processingTypeViewModel.ProcessingType);
                    db.SaveChanges();
                }
            }
            Back();
        }