public async Task <bool> Handle(RemoveClientCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return(false); } var client = await _clientRepository.FindByClientIdAsync(request.Client.ClientId); if (client == null) { await _bus.RaiseEvent(new DomainNotification("key_not_found", $"Client with ClientId {request.Client.ClientId} not found")); return(false); } await _clientRepository.RemoveAsync(client); if (Commit()) { await _bus.RaiseEvent(new ClientRemovedEvent(client.ClientId)); return(true); } return(false); }
public async Task Handle(RemoveClientCommand message) { if (!message.IsValid()) { NotifyValidationErrors(message); return; } await _clientRepository.DeleteLogicAsync(message.Id.ToString()); }