public async Task <IActionResult> UpdateConfigurationManagementService(Guid organizationId, Guid organizationCMSId, [FromBody] OrganizationCMSPutRp organizationCMSRp) { if (!ModelState.IsValid) { return(this.BadRequest(ModelState)); } await _organizationCMSService.UpdateConfigurationManagementService(organizationId, organizationCMSId, organizationCMSRp); 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()); }
public async Task UpdateConfigurationManagementService(Guid organizationId, Guid organizationCMSId, OrganizationCMSPutRp resource) { string 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; } PipelineRole role = user.GetRoleInOrganization(organizationId); if (role != PipelineRole.OrganizationAdmin) { await _domainManagerService.AddForbidden($"You are not authorized to update settings in this organization."); return; } OrganizationCMS organizationCMS = organization.GetConfigurationManagementServiceById(organizationCMSId); if (organizationCMS == null) { await _domainManagerService.AddConflict($"The cloud provider service with id {organizationCMSId} does not exists."); return; } user.UpdateConfigurationManagementService(organizationId, organizationCMSId, _dataProtectorService.Protect(resource.AccessId), _dataProtectorService.Protect(resource.AccessSecret)); _userRepository.Update(user); await _userRepository.SaveChanges(); }