コード例 #1
0
ファイル: ExternalReportExtension.cs プロジェクト: PiSim/LDb2
        /// <summary>
        /// Adds a new method to an ExternalReport entry
        /// </summary>
        /// <param name="methodEntity">The MethodVariant to Add</param>
        public void AddTestMethod(MethodVariant methodVariant)
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                ExternalReport attachedExternalReport = entities.ExternalReports.First(ext => ext.ID == ID);
                MethodVariant  attachedMethodVariant  = entities.MethodVariants.First(mtd => mtd.ID == methodVariant.ID);

                attachedExternalReport.MethodVariants.Add(attachedMethodVariant);

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

                methodVariant.LoadMethod(true);

                foreach (TestRecord tstr in attachedExternalReport.TestRecords)
                {
                    tstr.Tests.Add(methodVariant.GenerateTest());
                }

                entities.SaveChanges();
            }
        }