예제 #1
0
        public Task <bool> Handle(InactivatePersonCommand command, CancellationToken cancellationToken)
        {
            if (!command.IsValid())
            {
                NotifyValidationErrors(command);
                return(Task.FromResult(false));
            }

            var person = personReadRepository.GetById(command.Id);

            if (!person.Active)
            {
                mediator.RaiseEventAsync(new DomainNotification(command.MessageType, "A pessoa ja esta inativa!"));
                return(Task.FromResult(false));
            }

            person.InActivate();

            personWriteRepository.Update(person);

            if (Commit())
            {
                mediator.RaiseEventAsync(new InactivatePersonEvent(person.Id));
            }

            return(Task.FromResult(true));
        }
예제 #2
0
        public void Inactivate(Guid id)
        {
            var command = new InactivatePersonCommand(id);

            mediator.SendCommandAsync(command);
        }