Пример #1
0
        public async Task <ProjectServiceTemplateListRp> GetProjectServiceTemplates(ConfigurationManagementService gitProviderType, CloudProviderService cloudProviderType, PipeType pipeType)
        {
            var serviceTemplates = await _projectServiceTemplateRepository.GetProjectServiceTemplates(gitProviderType, cloudProviderType, pipeType);

            ProjectServiceTemplateListRp list = new ProjectServiceTemplateListRp
            {
                Items = serviceTemplates.Select(x => new ProjectServiceTemplateListItemRp()
                {
                    ProjectServiceTemplateId = x.ProjectServiceTemplateId,
                    Name        = x.Name,
                    Description = x.Description
                }).ToList()
            };

            return(list);
        }
Пример #2
0
        public async Task <OrganizationProjectServiceTemplateListRp> GetOrganizationProjectServiceTemplates(Guid organizationId, CloudProviderService cloudProviderType, PipeType pipeType)
        {
            var loggedUserId = _identityService.GetUserId();

            User user = await _userRepository.GetUser(loggedUserId);

            Organization organization = user.FindOrganizationById(organizationId);

            if (organization == null)
            {
                await _domainManagerService.AddNotFound($"The organzation with id {organizationId} does not exists.");

                return(null);
            }

            var systemTemplates = await _projectServiceTemplateRepository.GetProjectServiceTemplates(ConfigurationManagementService.VSTS, cloudProviderType, pipeType);

            OrganizationProjectServiceTemplateListRp list = new OrganizationProjectServiceTemplateListRp
            {
                Items = systemTemplates.Select(x => new OrganizationProjectServiceTemplateListItemRp()
                {
                    ProjectServiceTemplateId = x.ProjectServiceTemplateId,
                    Name                    = x.Name,
                    Description             = x.Description,
                    Access                  = x.TemplateAccess,
                    ProgrammingLanguageName = x.ProgrammingLanguage.Name,
                    Framework               = x.Framework,
                    Status                  = x.Status,
                    Logo                    = x.Logo
                }).ToList()
            };

            if (cloudProviderType == CloudProviderService.None)
            {
                var organizationAWSTemplates   = organization.GetProjectServiceTemplates(CloudProviderService.AWS, pipeType);
                var organizationAzureTemplates = organization.GetProjectServiceTemplates(CloudProviderService.Azure, pipeType);

                foreach (var item in organizationAWSTemplates)
                {
                    list.Items.Add(new OrganizationProjectServiceTemplateListItemRp()
                    {
                        ProjectServiceTemplateId = item.ProjectServiceTemplateId,
                        Name                    = item.Name,
                        Description             = item.Description,
                        Access                  = item.TemplateAccess,
                        ProgrammingLanguageName = item.ProgrammingLanguage.Name,
                        Framework               = item.Framework,
                        Status                  = item.Status
                    });
                }

                foreach (var item in organizationAzureTemplates)
                {
                    list.Items.Add(new OrganizationProjectServiceTemplateListItemRp()
                    {
                        ProjectServiceTemplateId = item.ProjectServiceTemplateId,
                        Name                    = item.Name,
                        Description             = item.Description,
                        Access                  = item.TemplateAccess,
                        ProgrammingLanguageName = item.ProgrammingLanguage.Name,
                        Framework               = item.Framework,
                        Status                  = item.Status
                    });
                }
            }
            else
            {
                var organizationTemplates = organization.GetProjectServiceTemplates(cloudProviderType, pipeType);
                foreach (var item in organizationTemplates)
                {
                    list.Items.Add(new OrganizationProjectServiceTemplateListItemRp()
                    {
                        ProjectServiceTemplateId = item.ProjectServiceTemplateId,
                        Name                    = item.Name,
                        Description             = item.Description,
                        Access                  = item.TemplateAccess,
                        ProgrammingLanguageName = item.ProgrammingLanguage.Name,
                        Framework               = item.Framework,
                        Status                  = item.Status
                    });
                }
            }


            return(list);
        }