Ejemplo n.º 1
0
        public void CreateNewRoute(Route route, Procescell procescell)
        {
            using (ConfigurationToolContext context = new ConfigurationToolContext())
            {
                var repository = new RouteRepository(context);
                var parameterDefinitionRepository = new ParameterDefinitionRepository(context);

                //Gets required parameters for a new procescell
                IEnumerable <ParameterDefinition> requiredParameters;
                requiredParameters = parameterDefinitionRepository.GetRequiredParameters("rop_RoutePars", procescell.prc_ProcescellTypeId);

                //convert parDef to proccellPars and add them to the procescell
                foreach (ParameterDefinition paf in requiredParameters)
                {
                    RouteParameter rop = new RouteParameter(route, paf, procescell);
                    route.RouteParameters.Add(rop);
                }

                repository.Add(route);
                context.SaveChanges();
            }
        }
        public void CreateNewProcescell(Procescell procescell)
        {
            using (ConfigurationToolContext context = new ConfigurationToolContext())
            {
                var repository = new ProcessCellRepository(context);
                var parameterDefinitionRepository = new ParameterDefinitionRepository(context);

                //Gets required parameters for a new procescell
                IEnumerable <ParameterDefinition> requiredParameters;
                requiredParameters = parameterDefinitionRepository.GetRequiredParameters("pca_ProcCellPars", procescell.prc_ProcescellTypeId);

                //convert parDef to proccellPars and add them to the procescell
                foreach (ParameterDefinition paf in requiredParameters)
                {
                    ProcessCellParameter pca = new ProcessCellParameter(procescell, paf);
                    procescell.ProcessCellParameters.Add(pca);
                }

                //this always happens at the end of the method
                repository.Add(procescell);
                context.SaveChanges();
            }
        }