示例#1
0
        public ProjectFeature CreateProjectFeature(Guid organizationId, Guid projectId, string name, string description)
        {
            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");
            }

            var newFeature = ProjectFeature.Factory.Create(name, description, this.Id);

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

            developmentProjectEnvironment.Activate();

            newFeature.AddEnvironment(developmentProjectEnvironment);

            project.AddFeature(newFeature);

            return(newFeature);
        }
示例#2
0
        public void AddEnvironment(ProjectFeatureEnvironment environment)
        {
            if (this.Environments == null)
            {
                this.Environments = new List <ProjectFeatureEnvironment>();
            }

            this.Environments.Add(environment);
        }
            public static ProjectFeatureEnvironment Create(string name, string description, EnvironmentType type, bool requiresApproval, int rank, string createdBy)
            {
                var entity = new ProjectFeatureEnvironment()
                {
                    Name             = name,
                    Description      = description,
                    Type             = type,
                    RequiresApproval = requiresApproval,
                    Rank             = rank,
                    CreatedBy        = createdBy
                };

                var validationResult = new DataValidatorManager <ProjectFeatureEnvironment>().Build().Validate(entity);

                if (!validationResult.IsValid)
                {
                    throw new ApplicationException(validationResult.Errors);
                }

                return(entity);
            }