public ICommandResult Handle(RegistraClienteComando command) { //valida CPF if (_clienteRepositorio.DocumentoExiste(command.Documento)) { AddNotification("Documento", "Este CPF está em Uso!"); return(null); } var nome = new Nome(command.PrimeiroNome, command.SegundoNome); var documento = new Documento(command.Documento); var email = new Email(command.Email); var usuario = new Usuario(command.Login, command.Senha, command.ConfirmaSenha); var cliente = new Cliente(nome, email, documento, usuario); AddNotifications(nome.Notifications); AddNotifications(documento.Notifications); AddNotifications(email.Notifications); AddNotifications(usuario.Notifications); AddNotifications(cliente.Notifications); if (!IsValid()) { return(null); } _clienteRepositorio.Save(cliente); _emailService.Send( cliente.Nome.ToString(), cliente.Email.Endereco, string.Format(EmailTemplates.WelcomeEmailTitle, cliente.Nome), string.Format(EmailTemplates.WelcomeEmailBody, cliente.Nome) ); return(new RegistraClienteComandoResult(cliente.Id, cliente.Nome.ToString())); }