public async Task <bool> Handle(RemoveFulanoCommand message, CancellationToken cancellationToken) { await _fulanoRepository.RemoveAsync(message.AggregateId); if (await Commit()) { await _mediatorHandler.RaiseDomainEventAsync(new FulanoRemovedEvent(message.Entity.Id)); } return(true); }
public override async Task RemoveAsync(Guid id) { var command = new RemoveFulanoCommand(id); if (!command.IsValid()) { await RaiseValidationErrorsAsync(command); return; } if ((await _fulanoRepository.GetByIdAsync(command.AggregateId)) == null) { await _mediatorHandler.RaiseDomainNotificationAsync(new DomainNotification(command.MessageType, CoreUserMessages.RegistroNaoEncontrado.Message)); return; } await _mediatorHandler.SendCommandAsync(command); }