Exemplo n.º 1
0
        public async Task <bool> Handle(DnaValidatorCommand request, CancellationToken cancellationToken)
        {
            var isMutant = await _dnaValidator.IsMutant(request.DnaList);

            var human = new Human(request.DnaList, isMutant);
            await _humanRepository.SaveAsync(human);

            await _mediator.Publish(new SavedHumanEvent()
            {
                IsMutant = isMutant
            }, cancellationToken);

            if (!isMutant)
            {
                throw new MutantNotFound();
            }
            return(true);
        }