示例#1
0
        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());
        }
示例#3
0
 public async Task Remove(RemoveClientCommand removeClientCommand)
 {
     await _bus.SendCommand(removeClientCommand);
 }
示例#4
0
        public void Remove(Guid id)
        {
            var removeCommand = new RemoveClientCommand(id);

            mediatorHandler.SendCommand(removeCommand);
        }
示例#5
0
 public async Task RemoveAsync(string clientId)
 {
     var command = new RemoveClientCommand(clientId);
     await _bus.SendCommand(command);
 }