Exemplo n.º 1
0
            public static ProjectEnvironmentVariable Create(Guid projectEnvironmentId, string name, string value, string createdBy)
            {
                var entity = new ProjectEnvironmentVariable()
                {
                    ProjectEnvironmentId = projectEnvironmentId,
                    Name      = name,
                    Value     = value,
                    CreatedBy = createdBy,
                    Status    = EntityStatus.Active
                };

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

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

                return(entity);
            }
Exemplo n.º 2
0
            public static ProjectServiceActivity Create(string code, string name, string createdBy)
            {
                var entity = new ProjectServiceActivity()
                {
                    Code           = code,
                    Name           = name,
                    ActivityStatus = ActivityStatus.Pending,
                    Log            = "Waiting",
                    CreatedBy      = createdBy
                };

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

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

                return(entity);
            }
Exemplo n.º 3
0
            public static CustomerMember Create(Guid teamMemberId, string userId, string email, CustomerMemberRole role, string createdBy)
            {
                var entity = new CustomerMember()
                {
                    CustomerMemberId = teamMemberId,
                    UserId           = userId,
                    Email            = email,
                    Role             = role,
                    CreatedBy        = createdBy
                };

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

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

                return(entity);
            }
            public static ProjectFeatureServiceDelivery Create(int versionId, string versionName)
            {
                var entity = new ProjectFeatureServiceDelivery()
                {
                    ProjectFeatureServiceDeliveryId = Guid.NewGuid(),
                    VersionId   = versionId,
                    VersionName = versionName,
                    CreatedBy   = "admin",
                    Status      = EntityStatus.Active
                };

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

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

                return(entity);
            }
Exemplo n.º 5
0
            public static UserPreference Create(string name, string value, string userId, string createdBy)
            {
                var entity = new UserPreference()
                {
                    Name      = name,
                    Value     = value,
                    Status    = EntityStatus.Active,
                    UserId    = userId,
                    CreatedBy = createdBy
                };

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

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

                return(entity);
            }
            public static OrganizationProjectServiceTemplate Create(Guid organizationId, Guid projectServiceTemplateId, string createdBy)
            {
                var entity = new OrganizationProjectServiceTemplate()
                {
                    OrganizationProjectServiceTemplateId = Guid.NewGuid(),
                    OrganizationId           = organizationId,
                    ProjectServiceTemplateId = projectServiceTemplateId,
                    CreatedBy = createdBy,
                    Status    = EntityStatus.Active
                };

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

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

                return(entity);
            }
            public static ProjectUser Create(Guid projectId, string userId, PipelineRole role, string createdBy)
            {
                var entity = new ProjectUser()
                {
                    ProjectUserId = Guid.NewGuid(),
                    ProjectId     = projectId,
                    UserId        = userId,
                    CreatedBy     = createdBy,
                    Status        = EntityStatus.Active,
                    Role          = role
                };

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

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

                return(entity);
            }
Exemplo n.º 8
0
            public static UserActivity Create(ActivityType type, string data, string userId, string createdBy)
            {
                var entity = new UserActivity()
                {
                    Type      = type,
                    Data      = data,
                    Status    = EntityStatus.Active,
                    Date      = DateTime.UtcNow,
                    UserId    = userId,
                    CreatedBy = createdBy
                };

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

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

                return(entity);
            }
            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);
            }
Exemplo n.º 10
0
            public static ProjectServiceTemplate Create(string name,
                                                        ConfigurationManagementService serviceCMSType,
                                                        CloudProviderService serviceCPSType,
                                                        string description,
                                                        string url,
                                                        string logo,
                                                        PipeType pipeType,
                                                        TemplateType templateType,
                                                        TemplateAccess templateAccess,
                                                        bool needCredentials,
                                                        Guid programmingLanguageId,
                                                        string framework,
                                                        string createdBy)
            {
                var entity = new ProjectServiceTemplate()
                {
                    Name                  = name,
                    ServiceCMSType        = serviceCMSType,
                    ServiceCPSType        = serviceCPSType,
                    Description           = description,
                    Url                   = url,
                    Logo                  = logo,
                    PipeType              = pipeType,
                    TemplateType          = templateType,
                    TemplateAccess        = templateAccess,
                    NeedCredentials       = needCredentials,
                    ProgrammingLanguageId = programmingLanguageId,
                    Framework             = framework,
                    CreatedBy             = createdBy
                };

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

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

                return(entity);
            }
            public static OrganizationCMS Create(string name,
                                                 ConfigurationManagementService type,
                                                 CMSConnectionType connectionType,
                                                 string accountId,
                                                 string accountName,
                                                 string accessId,
                                                 string accessSecret,
                                                 string accessToken,
                                                 string createdBy)
            {
                var entity = new OrganizationCMS()
                {
                    Name           = name,
                    Type           = type,
                    ConnectionType = connectionType,
                    AccountId      = accountId,
                    AccountName    = accountName,
                    AccessId       = accessId,
                    AccessSecret   = accessSecret,
                    AccessToken    = accessToken,
                    CreatedBy      = createdBy,
                    Status         = EntityStatus.Active
                };

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

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

                if ((type == ConfigurationManagementService.VSTS ||
                     type == ConfigurationManagementService.Bitbucket) && string.IsNullOrEmpty(accessSecret))
                {
                    throw new ApplicationException("Access Secret is required");
                }

                return(entity);
            }
Exemplo n.º 12
0
            public static Customer Create(Guid customerId, string name, string userId, string adminName, string adminEmail, string createdBy)
            {
                var entity = new Customer()
                {
                    CustomerId = customerId,
                    Name       = name,
                    AdminName  = adminName,
                    AdminEmail = adminEmail,
                    CreatedBy  = createdBy
                };

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

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

                entity.AddMember(Guid.NewGuid(), userId, adminEmail, CustomerMemberRole.Admin, createdBy, true);

                return(entity);
            }
Exemplo n.º 13
0
            public static OrganizationUserInvitation Create(Guid organizationId, string userId, string userEmail, PipelineRole role, string createdBy)
            {
                var entity = new OrganizationUserInvitation()
                {
                    OrganizationId   = organizationId,
                    UserId           = userId,
                    UserEmail        = userEmail,
                    InvitationType   = string.IsNullOrEmpty(userId) ? UserInvitationType.ExternalUser : UserInvitationType.InternalUser,
                    Role             = role,
                    InvitationStatus = UserInvitationStatus.Pending,
                    CreatedBy        = createdBy,
                    Status           = EntityStatus.Active
                };

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

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

                return(entity);
            }
            public static Organization Create(string name, string description, string webSiteUrl, string ownerId, string createdBy)
            {
                var entity = new Organization()
                {
                    Name        = name,
                    Description = description,
                    WebSiteUrl  = webSiteUrl,
                    OwnerId     = ownerId,
                    CreatedBy   = createdBy,
                    Status      = EntityStatus.Active
                };

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

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

                entity.GrantUserAccess(createdBy, PipelineRole.OrganizationAdmin);

                return(entity);
            }
Exemplo n.º 15
0
            public static User Create(string firstName, string lastName, string email, string password)
            {
                var entity = new User()
                {
                    FirstName          = firstName,
                    LastName           = lastName,
                    Email              = email,
                    PasswordHash       = password,
                    UserName           = email,
                    ConcurrencyStamp   = Guid.NewGuid().ToString(),
                    SecurityStamp      = Guid.NewGuid().ToString(),
                    NormalizedEmail    = email.ToUpper(),
                    NormalizedUserName = email.ToUpper()
                };

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

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

                return(entity);
            }
            public static OrganizationCPS Create(string name, CloudProviderService type,
                                                 string accessId,
                                                 string accessName,
                                                 string accessSecret,
                                                 string accessAppId,
                                                 string accessAppSecret,
                                                 string accessDirectory,
                                                 string accessRegion,
                                                 string createdBy)
            {
                var entity = new OrganizationCPS()
                {
                    Name            = name,
                    Type            = type,
                    AccessId        = accessId,
                    AccessName      = accessName,
                    AccessSecret    = accessSecret,
                    AccessAppId     = accessAppId,
                    AccessAppSecret = accessAppSecret,
                    AccessDirectory = accessDirectory,
                    AccessRegion    = accessRegion,
                    CreatedBy       = createdBy,
                    Status          = EntityStatus.Active
                };

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

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

                if (type == CloudProviderService.AWS)
                {
                    if (string.IsNullOrEmpty(accessSecret))
                    {
                        throw new ApplicationException("Access Secret is required");
                    }
                }

                if (type == CloudProviderService.Azure)
                {
                    if (string.IsNullOrEmpty(accessName))
                    {
                        throw new ApplicationException("Subscription Name is required");
                    }

                    if (string.IsNullOrEmpty(accessAppId))
                    {
                        throw new ApplicationException("Application Id is required");
                    }

                    if (string.IsNullOrEmpty(accessAppSecret))
                    {
                        throw new ApplicationException("Application Secret is required");
                    }

                    if (string.IsNullOrEmpty(accessDirectory))
                    {
                        throw new ApplicationException("Directory is required");
                    }
                }

                return(entity);
            }