public async Task <bool> Handle(UpdateIdentityResourceCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return(false); } var name = request.OldIdentityResourceName != request.IdentityResource.Name ? request.OldIdentityResourceName : request.IdentityResource.Name; var resource = await _identityResourceRepository.FirstOrDefaultAsync(r => r.Name == name); if (resource == null) { await _bus.RaiseEvent(new DomainNotification("key_not_found", $"IdentityResource named {name} could not be found")); return(false); } var vm = request.IdentityResource.ToEntity(); resource.Name = vm.Name; resource.DisplayName = vm.DisplayName; resource.Description = vm.Description; resource.Enabled = vm.Enabled; resource.Emphasize = vm.Emphasize; resource.ShowInDiscoveryDocument = vm.ShowInDiscoveryDocument; resource.Properties = vm.Properties; resource.Required = vm.Required; resource.Updated = DateTime.UtcNow; resource.UserClaims = vm.UserClaims; await _identityResourceRepository.UpdateWithChildrensAsync(resource); if (Commit()) { await _bus.RaiseEvent(new IdentityResourceUpdatedEvent(resource.Id, request.IdentityResource.Name, request.OldIdentityResourceName)); return(true); } return(false); }