Exemplo n.º 1
0
        public ExternalConstruction CreateNewExternalConstruction()
        {
            ExternalConstruction newEntry = new ExternalConstruction();
            IEnumerable <ExternalConstruction> tempList = _labDbData.RunQuery(new ExternalConstructionsQuery()).ToList();

            int    nameCounter = 1;
            string curName     = "Nuova Construction";

            while (true)
            {
                if (!tempList.Any(exc => exc.Name == curName))
                {
                    break;
                }
                else
                {
                    curName = "Nuova Construction " + nameCounter++;
                }
            }
            newEntry.Name  = curName;
            newEntry.OemID = 1;

            newEntry.Create();

            return(newEntry);
        }
Exemplo n.º 2
0
 public static void Update(this ExternalConstruction entry)
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.ExternalConstructions.AddOrUpdate(entry);
         entities.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public static void Create(this ExternalConstruction entry)
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.ExternalConstructions.Attach(entry);
         entities.Entry(entry).State = System.Data.Entity.EntityState.Added;
         entities.SaveChanges();
     }
 }
Exemplo n.º 4
0
        public static void AddMaterial(this ExternalConstruction entry,
                                       Material toBeAdded)
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Materials.First(mat => mat.ID == toBeAdded.ID)
                .ExternalConstructionID = entry.ID;

                entities.SaveChanges();
            }
        }
Exemplo n.º 5
0
        public static void Delete(this ExternalConstruction entry)
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Entry(entities
                               .ExternalConstructions
                               .First(exc => exc.ID == entry.ID))
                .State = System.Data.Entity.EntityState.Deleted;
                entities.SaveChanges();

                entry.ID = 0;
            }
        }