Ejemplo n.º 1
0
        public async Task <ResponseCommand> Handle(CreateContaCommand command)
        {
            var response = new ResponseCommand();

            command.Validate();
            if (command.Invalid)
            {
                response.AddNotifications(command.Notifications);
                return(response);
            }

            if (await _contaRepository.ContaExiste(command.NumeroConta))
            {
                response.AddNotification(new Notification("Conta", "A conta informada já existe!"));
                return(response);
            }

            var conta = new ContaCorrente(command.NumeroConta);
            await _contaRepository.CadastrarConta(conta);

            response.AddValue(command.NumeroConta);

            return(response);
        }