示例#1
0
        public ICommandResult Handle(GenerateCustomerCodeCommand command)
        {
            //Validar command
            command.Validate();

            if (!_customerRepository.CheckEmail(command.Email))
            {
                return(new GenericCommandResult());
            }

            var customer = _customerRepository.GetByEmail(command.Email);

            //Criar entidades
            var code = new Code(customer.Id);

            //Persistir no banco
            _codeRepository.Save(code);

            //Enviar sms
            _smsService.Send(customer.Phone, $"Codigo plataforma Controle Financeiro:\n\n{code.CodeValue}\n\n\n");

            return(new GenericCommandResult(true, $"Código de validação enviado para o numero {customer.Phone}", null));
        }
示例#2
0
 public ICommandResult GetCode([FromBody] GenerateCustomerCodeCommand command)
 {
     return(_handler.Handle(command));
 }