Esempio n. 1
0
        /// <summary>
        /// Deletes the entry from the database if no Test or requirement is associated with it, otherwise sets it as obsolete
        /// </summary>
        public void RemoveOrSetObsolete()
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                MethodVariant attachedInstance = entities.MethodVariants.FirstOrDefault(mtdvar => mtdvar.ID == ID);
                if (attachedInstance == null)
                {
                    return;
                }

                if (attachedInstance.Requirements.Count == 0 &&
                    attachedInstance.Tests.Count == 0)
                {
                    entities.Entry(attachedInstance)
                    .State = EntityState.Deleted;
                }
                else
                {
                    attachedInstance.IsOld = true;
                    IsOld = true;
                }

                entities.SaveChanges();
            }
        }
Esempio n. 2
0
 public static void Delete(this Specification entry)
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.Entry(entities.Specifications.First(spec => spec.ID == entry.ID))
         .State = EntityState.Deleted;
         entities.SaveChanges();
     }
 }
Esempio n. 3
0
 public static void Delete(this Method entry)
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.Methods.Attach(entry);
         entities.Entry(entry).State = System.Data.Entity.EntityState.Deleted;
         entities.SaveChanges();
     }
 }
Esempio n. 4
0
        public static void Delete(this Report entry)
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Entry(entities.Reports.First(rep => rep.ID == entry.ID)).State = EntityState.Deleted;
                entities.SaveChanges();

                entry.ID = 0;
            }
        }
Esempio n. 5
0
        public static void Delete(this Batch entry)
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                Batch tempEntry = entities.Batches.First(btc => btc.ID == entry.ID);

                entities.Entry(tempEntry).State = EntityState.Deleted;
                entry.ID = 0;

                entities.SaveChanges();
            }
        }
 public static void Delete(this SpecificationVersion entry)
 {
     // Deletes SpecificationVersion entity
     {
         using (LabDbEntities entities = new LabDbEntities())
         {
             entities.SpecificationVersions.Attach(entry);
             entities.Entry(entry).State = EntityState.Deleted;
             entities.SaveChanges();
         }
     }
 }
Esempio n. 7
0
        public static void Delete(this Task entry)
        {
            // Deletes given task instance

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

                entities.SaveChanges();
            }
        }
Esempio n. 8
0
        public static void Delete(this Instrument entry)
        {
            // Deletes an Instrument entry

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

                entities.SaveChanges();

                entry.ID = 0;
            }
        }
Esempio n. 9
0
        public void Delete()
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                ControlPlan tempEntry = entities.ControlPlans.FirstOrDefault(cp => cp.ID == ID);
                if (tempEntry != null)
                {
                    entities.Entry(tempEntry)
                    .State = System.Data.Entity.EntityState.Deleted;
                    entities.SaveChanges();
                }

                ID = 0;
            }
        }
Esempio n. 10
0
        public static void Delete(this Requirement entry)
        {
            // Deletes Requirement entry

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

                entities.SaveChanges();

                entry.ID = 0;
            }
        }
Esempio n. 11
0
        public void Delete()
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                Project tempEntry = entities.Projects.FirstOrDefault(prj => prj.ID == ID);

                if (tempEntry != null)
                {
                    entities.Entry(tempEntry)
                    .State = EntityState.Deleted;

                    entities.SaveChanges();
                }

                entities.SaveChanges();
            }
        }
Esempio n. 12
0
        public static void Load(this Requirement entry)
        {
            // Loads DB values a given Requirement entry

            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                entities.Requirements.Attach(entry);

                Requirement tempEntry = entities.Requirements.Include(req => req.MethodVariant.Method.Property)
                                        .Include(req => req.MethodVariant.Method.Standard.Organization)
                                        .Include(req => req.Overridden)
                                        .Include(req => req.SubRequirements)
                                        .First(req => req.ID == entry.ID);

                entities.Entry(entry).CurrentValues.SetValues(tempEntry);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Removes a given methodVariant from the method associations and from every test record
        /// in the report
        /// </summary>
        /// <param name="methodEntity">The methodVariant that will be removed</param>
        public void RemoveTestMethodVariant(MethodVariant methodVariantEntity)
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                ExternalReport attachedExternalReport = entities.ExternalReports.First(ext => ext.ID == ID);
                MethodVariant  attachedMethodVariant  = entities.MethodVariants.First(mtdvar => mtdvar.ID == methodVariantEntity.ID);

                attachedExternalReport.MethodVariants.Remove(attachedMethodVariant);

                IEnumerable <TestRecord> recordList = attachedExternalReport.TestRecords.ToList();

                IEnumerable <Test> testList = attachedExternalReport.TestRecords.SelectMany(tstr => tstr.Tests)
                                              .Where(tst => tst.MethodVariantID == methodVariantEntity.ID)
                                              .ToList();

                foreach (Test tst in testList)
                {
                    entities.Entry(tst).State = EntityState.Deleted;
                }

                entities.SaveChanges();
            }
        }