Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }