Example #1
0
        public static void AddMeasurableQuantityAssociation(this InstrumentType entry,
                                                            MeasurableQuantity quantity)
        {
            // Create a new association between an instrument Type and a quantity

            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.InstrumentTypes
                .First(ist => ist.ID == entry.ID)
                .MeasurableQuantities
                .Add(entities
                     .MeasurableQuantities
                     .First(meq => meq.ID == quantity.ID));

                entities.SaveChanges();
            }
        }
Example #2
0
        public static void RemoveMeasurableQuantityAssociation(this InstrumentType entry,
                                                               MeasurableQuantity quantity)
        {
            // Removes an association between an instrument Type and a quantity

            using (LabDbEntities entities = new LabDbEntities())
            {
                MeasurableQuantity toBeRemoved = entities.MeasurableQuantities
                                                 .First(meq => meq.ID == quantity.ID);

                entities.InstrumentTypes
                .First(ist => ist.ID == entry.ID)
                .MeasurableQuantities
                .Remove(toBeRemoved);

                entities.SaveChanges();
            }
        }
Example #3
0
        public MeasurableQuantity CreateNewMeasurableQuantity()
        {
            StringInputDialog creationDialog = new StringInputDialog
            {
                Title = "Crea nuova quantità misurabile"
            };

            if (creationDialog.ShowDialog() == true)
            {
                MeasurableQuantity output = new MeasurableQuantity()
                {
                    Name = creationDialog.InputString
                };

                _labDbData.Execute(new InsertEntityCommand(output));
                return(output);
            }

            return(null);
        }
 public void SetQuantity(MeasurableQuantity entry)
 {
     _selectedMeasurableQuantity = MeasurableQuantityList.First(meq => meq.ID == entry.ID);
     RaisePropertyChanged("SelectedMeasurableQuantity");
 }