Ejemplo n.º 1
0
        public InstrumentUtilizationAreaMainViewModel(IDataService <LInstContext> lInstData)
        {
            _lInstData = lInstData;

            CreateAreaCommand = new DelegateCommand(
                () =>
            {
                Controls.Views.StringInputDialog inputDialog = new Controls.Views.StringInputDialog();
                inputDialog.Message = "Inserire il nome della nuova area:";

                if (inputDialog.ShowDialog() == true)
                {
                    InstrumentUtilizationArea newArea = new InstrumentUtilizationArea()
                    {
                        Name  = inputDialog.InputString,
                        Plant = "1"
                    };

                    _lInstData.Execute(new InsertEntityCommand <LInstContext>(newArea));

                    RaisePropertyChanged("UtilizationAreaList");
                }
            });

            DeleteAreaCommand = new DelegateCommand(
                () =>
            {
                _lInstData.Execute(new DeleteEntityCommand <LInstContext>(_selectedArea));
                SelectedArea = null;
            },
                () => _selectedArea != null);
        }
Ejemplo n.º 2
0
        public static void Create(this InstrumentUtilizationArea entry)
        {
            // Inserts a new InstrumentUtilizationArea entry in the DB

            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.InstrumentUtilizationAreas.Add(entry);
                entities.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public static void Delete(this InstrumentUtilizationArea entry)
        {
            // Deletes an InstrumentUtilizationArea entry

            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Entry(entities
                               .InstrumentUtilizationAreas
                               .First(iua => iua.ID == entry.ID))
                .State = EntityState.Deleted;

                entities.SaveChanges();
                entry.ID = 0;
            }
        }