Example #1
0
        public async Task <IActionResult> ImportProjectService(Guid organizationId, Guid projectId, [FromBody] ProjectServiceImportPostRp projectServiceRp)
        {
            if (!ModelState.IsValid)
            {
                return(this.BadRequest(ModelState));
            }

            await _projectServiceService.ImportProjectService(organizationId, projectId, projectServiceRp);

            if (_domainManagerService.HasNotFounds())
            {
                return(this.NotFound(_domainManagerService.GetNotFounds()));
            }

            if (_domainManagerService.HasForbidden())
            {
                return(this.Forbidden(_domainManagerService.GetForbidden()));
            }

            if (_domainManagerService.HasConflicts())
            {
                return(this.Conflict(_domainManagerService.GetConflicts()));
            }

            return(this.Ok(new { ServiceId = await _domainManagerService.GetResult <Guid>("ServiceId") }));
        }
        public async Task <IActionResult> ImportProjectService(Guid organizationId, Guid projectId, [FromBody] InternalProjectServiceImportPostRp projectServiceRp)
        {
            if (!ModelState.IsValid)
            {
                return(this.BadRequest(ModelState));
            }

            ProjectServiceImportPostRp resource = new ProjectServiceImportPostRp();

            resource.Name                = projectServiceRp.Name;
            resource.Description         = projectServiceRp.Description;
            resource.ServiceExternalId   = projectServiceRp.ServiceExternalId;
            resource.ServiceExternalUrl  = projectServiceRp.ServiceExternalUrl;
            resource.ServiceExternalName = projectServiceRp.ServiceExternalName;
            resource.BranchName          = projectServiceRp.BranchName;
            resource.OrganizationCMSId   = projectServiceRp.OrganizationCMSId;
            resource.BuildDefinitionYML  = projectServiceRp.BuildDefinitionYML;
            resource.ProjectExternalId   = projectServiceRp.ProjectExternalId;
            resource.ProjectExternalName = projectServiceRp.ProjectExternalName;

            resource.ProjectServiceTemplateId = projectServiceRp.ProjectServiceTemplateId;

            await _projectServiceService.ImportProjectService(organizationId, projectId, resource, projectServiceRp.UserId);

            if (_domainManagerService.HasNotFounds())
            {
                return(this.NotFound(_domainManagerService.GetNotFounds()));
            }

            if (_domainManagerService.HasConflicts())
            {
                return(this.Conflict(_domainManagerService.GetConflicts()));
            }

            return(this.Ok());
        }