Пример #1
0
        public Project CreateProject(Guid organizationId, string organizationExternalId, string name, string description, ProjectType projectType,
                                     Guid organizationCMSId, Guid?organizationCPSId, Guid?projectTemplateId, string agentPoolId,
                                     ProjectVisibility projectVisibility, CloudProviderService cloudProviderService, ConfigurationManagementService configurationManagementService)
        {
            Organization organization = FindOrganizationById(organizationId);

            if (organization == null)
            {
                throw new ApplicationException($"The organization with id {organizationId} does not exists");
            }

            Project newProject = Project.Factory.Create(organizationExternalId, name, description, projectType, organizationCMSId, organizationCPSId,
                                                        projectTemplateId, agentPoolId, projectVisibility, cloudProviderService, configurationManagementService, this.Id);

            ProjectEnvironment developmentProjectEnvironment = ProjectEnvironment.Factory.Create(DomainConstants.Environments.Development, "Environment for development and some tests", EnvironmentType.Root, false, false, 1, this.Id);

            developmentProjectEnvironment.Activate();

            newProject.AddEnvironment(developmentProjectEnvironment);

            ProjectEnvironment productionProjectEnvironment = ProjectEnvironment.Factory.Create(DomainConstants.Environments.Production, "Environment for production", EnvironmentType.Fact, true, false, 2, this.Id);

            productionProjectEnvironment.Activate();

            newProject.AddEnvironment(productionProjectEnvironment);

            organization.AddProject(newProject);

            return(newProject);
        }
Пример #2
0
        public ProjectEnvironment CreateProjectEnvironment(Guid organizationId, Guid projectId, string name, string description, bool requiresApproval, bool autoProvision)
        {
            Organization organization = FindOrganizationById(organizationId);

            if (organization == null)
            {
                throw new ApplicationException($"The organization with id {organizationId} does not exists");
            }

            Project project = organization.GetProjectById(projectId);

            if (project == null)
            {
                throw new ApplicationException($"The project with id {projectId} does not exists");
            }

            //Reorder
            var productionEnvironment = project.GetProductionEnvironment();

            var newEnvironment = ProjectEnvironment.Factory.Create(name, description, EnvironmentType.Plan, requiresApproval, autoProvision, productionEnvironment.Rank, this.Id);

            project.AddEnvironment(newEnvironment);

            productionEnvironment.Rank = productionEnvironment.Rank + 1;

            return(newEnvironment);
        }