Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        public void AddMethod(Requirement requirementEntry)
        {
            // Adds a requirement to a Specification

            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.SpecificationVersions
                .First(spcv => spcv.SpecificationID == ID && spcv.IsMain)
                .Requirements
                .Add(requirementEntry);

                foreach (ControlPlan cp in entities.ControlPlans.Where(cp => cp.SpecificationID == ID))
                {
                    requirementEntry.ControlPlanItems
                    .Add(new ControlPlanItem()
                    {
                        ControlPlan = cp,
                        IsSelected  = cp.IsDefault
                    });
                }

                entities.SaveChanges();
            }
        }