Beispiel #1
0
        public async Task <bool> IsMutant(string[] dna)
        {
            _logger.LogDebug("Validating dna.");
            bool isMutant = await _dnaValidator.IsMutant(dna);

            _dataRepository.Add(new Dna()
            {
                DnaString = dna, IsMutant = isMutant
            });
            return(isMutant);
        }
Beispiel #2
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);
        }