Ejemplo n.º 1
0
 public void AddCredential(ConfigurationManagementService cmsType, bool needCredentials, string accessId, string accessSecret, string accessToken)
 {
     if (needCredentials)
     {
         this.Credential = ProjectServiceTemplateCredential.Factory.Create(cmsType, accessId, accessSecret, accessToken, this.CreatedBy);
     }
     else
     {
         this.Credential = ProjectServiceTemplateCredential.Factory.Create(cmsType, this.CreatedBy);
     }
 }
Ejemplo n.º 2
0
            public static ProjectServiceTemplateCredential Create(ConfigurationManagementService CMSType,
                                                                  string accessId,
                                                                  string accessSecret,
                                                                  string accessToken,
                                                                  string createdBy)
            {
                var entity = new ProjectServiceTemplateCredential()
                {
                    CMSType      = CMSType,
                    AccessId     = accessId,
                    AccessSecret = accessSecret,
                    AccessToken  = accessToken,
                    CreatedBy    = createdBy,
                    Status       = EntityStatus.Active
                };

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

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

                if (CMSType == ConfigurationManagementService.VSTS)
                {
                    if (string.IsNullOrEmpty(accessId))
                    {
                        throw new ApplicationException("Access Id is required");
                    }

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

                if (CMSType == ConfigurationManagementService.GitHub)
                {
                    if (string.IsNullOrEmpty(accessId))
                    {
                        throw new ApplicationException("Access Id is required");
                    }

                    if (string.IsNullOrEmpty(accessToken))
                    {
                        throw new ApplicationException("Access Token is required");
                    }
                }

                return(entity);
            }
Ejemplo n.º 3
0
            public static ProjectServiceTemplateCredential Create(ConfigurationManagementService CMSType, string createdBy)
            {
                var entity = new ProjectServiceTemplateCredential()
                {
                    CMSType   = CMSType,
                    CreatedBy = createdBy,
                    Status    = EntityStatus.Active
                };

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

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

                return(entity);
            }