public async Task <SetApiScopeResponse> SetApiScopeAsync(SetApiParam param, CancellationToken cancellationToken) { var retVal = new SetApiScopeResponse(); var apiScope = await _repository.GetApiScopeAsync(new GatApiScopeParam { Authority = param.Authority, Name = param.Name }, cancellationToken); if (apiScope == null) { apiScope = new ApiScope { Name = param.Name, DisplayName = param.Name // ensure got display name if not set from param }; retVal.Created = true; } if (!string.IsNullOrEmpty(param.DisplayName)) { apiScope.DisplayName = param.DisplayName; } if (!param.DryRun) { await _repository.SetApiScopeAsync(apiScope, param, cancellationToken); } retVal.ApiScope = apiScope; retVal.DryRun = param.DryRun; return(retVal); }