public async Task <bool> Handle(RemoveIdentityResourceCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return(false); } var savedClient = await _identityResourceRepository.GetByName(request.Resource.Name); if (savedClient == null) { await Bus.RaiseEvent(new DomainNotification("1", "Resource not found")); return(false); } _identityResourceRepository.Remove(savedClient.Id); if (Commit()) { await Bus.RaiseEvent(new IdentityResourceRemovedEvent(request.Resource.Name)); return(true); } return(false); }
public async Task <bool> Handle(RemoveIdentityResourceCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return(false); } var resource = await _identityResourceRepository.FirstOrDefaultAsync(r => r.Name == request.IdentityResource.Name); if (resource != null) { await _identityResourceRepository.RemoveAsync(resource); if (Commit()) { await _bus.RaiseEvent(new IdentityResourceRemovedEvent(resource.Id)); return(true); } } return(false); }