public async Task <bool> Handle(SetApiScopeCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return(false); } var resource = await _apiResourceRepository.FindByNameAsync(request.ApiResourceName); if (resource == null) { await _bus.RaiseEvent(new DomainNotification("key_not_found", $"{request.ApiResourceName} not found")); return(false); } var scope = new ApiScope { ApiResource = resource, Description = request.Description, Required = request.Required, DisplayName = request.DisplayName, Emphasize = request.Emphasize, Name = request.Name, ShowInDiscoveryDocument = request.ShowInDiscoveryDocument, UserClaims = request.UserClaims.Select(s => new ApiScopeClaim() { Type = s }).ToList(), }; await _apiScopeRepository.AddAsync(scope); if (Commit()) { return(true); } return(false); }