public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            //Fail Fast Validations
            command.Validate();

            if (command.Invalid)
            {
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            // Verificar se Documento já esta cadastrado
            if (_studentRepository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF já está em uso");
            }

            // Verificar se E-mail já esta cadastrado
            if (_studentRepository.EmailExists(command.Email))
            {
                AddNotification("email", "Este E-mail já está em uso");
            }

            //Criar Pagamento
            var payment = new BoletoPayment(command.BarCode,
                                            command.BoletoNumber,
                                            command.PaidDate,
                                            command.ExpireDate,
                                            command.Total,
                                            command.TotalPaid,
                                            command.Payer,
                                            new Address(command.Street,
                                                        command.Number,
                                                        command.Nighborhood,
                                                        command.City,
                                                        command.State,
                                                        command.Country,
                                                        command.ZipCode),
                                            new Document(command.PayerDocument, command.PayerDocumentType),
                                            new Email(command.Email));

            var student = CrateStudentFactory(command, payment);

            //agrupar as Validações
            AddNotifications(student.Name,
                             student.Document,
                             student.Email,
                             student.Address,
                             student,
                             student.Subscriptions.First(),
                             payment);

            // Salvar as Informações
            _studentRepository.CreateSubscription(student);

            // Enviar E-mail de boas vindas
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao andre.io", "sua assinatura foi criada");

            // Retornar informações
            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            //Fail fast validations
            command.Validate();

            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            //verificar se documento já está cadastrado
            // AddNotifications(new Contract()
            // );
            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF já está em uso");
                //AddNotifications(command);
                //return new CommandResult(false, "Não foi possível realizar sua assinatura");
            }

            //verificar se email já está cadastrado
            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "Este e-mail já está em uso");
            }

            //gerar os VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            //gerar as entidades
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, email);

            //relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            //agrupar as validações
            AddNotifications(name, document, email, address, student, subscription, payment);

            //checar as notificacoes
            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possivel realizar a sua assinatura"));
            }

            //salvar as informações
            _repository.CreateSubscription(student);

            //enviar e-mail de boas vindas
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao curso", "Sua assinatura foi criada");

            //retornar informações
            return(new CommandResult(true, "Assinatura realizada com sucesso!"));
        }
Пример #3
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            //  Fail Fast Validation
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possivel realizar sua assinatura"));
            }

            //  Verificar se Documento ja esta cadastrado
            if (_repository.DocumentsExists(command.Document))
            {
                AddNotification("Document", "Este CPF ja esta em uso");
            }

            //  Verificar se E=mail ja esta cadastrado
            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "Este E-mail ja esta em uso");
            }

            //  Gerar os VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.cpf);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);


            //  Gerar as entidades
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddDays(30));
            var payment      = new BoletoPayment(
                command.BarCode,
                command.BoletoNumber,
                command.PaidDate,
                command.ExpireDate,
                command.Total,
                command.TotalPaid,
                command.Payer, new Document(command.PayerDocument, command.PayerDocumentType),
                address,
                email
                );

            //  Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            //  Agrupar as validaçoes
            AddNotifications(name, document, email, address, student, subscription, payment);

            //  Salvar as Informaçoes
            _repository.CreateSubscription(student);

            //  Enviar E-mail de boas vindas
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao TOMENOS ENTERPRISE", "Sua assinatura foi criada");

            //  Retornar informações
            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }
Пример #4
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            // Fail Fast Validations
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possivel realizar sua assinatura."));
            }

            // Verificar se documento ja esta cadastrado.
            if (_repository.DocumentExists(command.DocumentNumber))
            {
                AddNotification("Document", "Este CPF já esta em uso");
            }

            // Verificar se email ja esta cadastrado
            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "Este email ja esta em uso");
            }

            // Gerar os VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.DocumentNumber, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.AddressNumber, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);


            // Gerar as Entidades
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode, command.BoletoNumber,
                                                 command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid,
                                                 command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, email);

            // Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            // Aplicar as validações
            AddNotifications(name, document, email, address, student, subscription, payment);

            // Checar notificações
            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possivel realizar sua assinatura."));
            }

            // Salvar as informações
            _repository.CreateSubscription(student);

            // Enviar email de boas vindas.
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Boas Vindas", $"Welcome {student.Name.ToString()}, sua assinatura foi criada!");

            // Retornar informações.


            return(new CommandResult(true, "Assinatura realizada com sucesso."));
        }
        public static BoletoPayment BoletoTransactionResponse()
        {
            var paymentId = Guid.NewGuid();

            var boletoTransaction = new BoletoPayment
            {
                Amount        = 15057,
                Provider      = ProviderEnum.Bradesco,
                Country       = "BRA",
                Currency      = "BRL",
                PaymentId     = paymentId,
                ReasonCode    = 0,
                Type          = "Boleto",
                ReasonMessage = "Successful",
                Status        = 1,
                Links         = new List <Link>
                {
                    new Link
                    {
                        Href   = "https://apisandbox.braspag.com.br/v2/sales/" + paymentId,
                        Method = "GET",
                        Rel    = "self"
                    }
                }
            };

            return(boletoTransaction);
        }
        public ICommandResult Handler(CreateBoletoSubscriptionCommand command)
        {
            //Fail Fast Validation
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            //Verifica se o documento já esta cadastrado!
            if (studentyRepository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF já está em uso");
            }

            if (studentyRepository.EmailExists(command.Email))
            {
                AddNotification("Email", "Este email já está em uso");
            }

            //Entities e V.O.
            var name         = new Name(command.FirstName, command.LastName);
            var email        = new Email(command.Email);
            var address      = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Contry, command.ZipCode);
            var document     = new Document(command.Document, EDocumentType.CPF);
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));

            var payment = new BoletoPayment(command.BarCode,
                                            command.BoletoNumber,
                                            command.PaidDate,
                                            command.ExpireDate,
                                            command.Total,
                                            command.TotalPaid,
                                            command.Payer, new Document(command.PayerDocument, command.PayerDocumentType),
                                            address, email);

            //Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            //Agrupa as validações
            AddNotifications(name, document, address, student, subscription, payment);

            //Valida
            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            //Salva as informacoes
            studentyRepository.CreateSubscription(student);

            //Envia e-mail de boas vindas
            emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo", "Sua assinatura foi criada!");

            //retorna as informações
            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }
Пример #7
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            //Fail Fast Validations

            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "It was not possible create subscription"));
            }

            //Verify if document has been saved
            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF ja esta em uso");
            }

            //verifify if e-mail has been saved
            if (_repository.EmailExists(command.Email))
            {
                AddNotification("E-mail", "Este E-mail ja esta em uso");
            }

            //Create VO's
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            //Create Entities
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode,
                                                 command.BoletoNumber,
                                                 command.PaidDate,
                                                 command.ExpireDate,
                                                 command.Total,
                                                 command.TotalPaid,
                                                 command.Payer,
                                                 new Document(command.Document, EDocumentType.CPF),
                                                 address,
                                                 email
                                                 );

            // Relationships
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            //Group validations
            AddNotifications(name, document, email, address, student, subscription, payment);

            //Save information
            _repository.CreateSubscriprion(student);

            //Send welcome e-mail
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Welcome", "Your subscription has been created");

            //return information
            return(new CommandResult(true, "Subscription success"));
        }
Пример #8
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            //Fail Fast Validations
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar seu cadastro"));
            }

            //Verificar se Documento já está cadastrado
            if (_repository.DocumentExists(command.Document))
            {
                AddNotifications(command);
            }
            //Pode ser utilizado o AddNotifications
            AddNotifications(new Contract()
                             .Requires()
                             .IsNotNullOrEmpty(command.Email, "Cadastro", "E-mail Inválido!")
                             );

            //Verificar se Email já está cadastrado
            if (_repository.EmailExists(command.Email))
            {
                AddNotifications(command);
            }
            //Gerar os VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neightborhood, command.City, command.Country, command.ZipCode);

            //Gerar as Entidades
            var student      = new Student(name, document, email, address);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.PaidDate, command.ExpireDate, command.Total, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), command.TotalPaid, address, email);

            //Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            //Agrupar as Validações
            AddNotifications(name, document, address, student, subscription, payment);

            //Checar as notificações
            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possível efetivar sua assinatura!"));
            }

            //Persistir as informações
            _repository.CreateSubscription(student);

            //Enviar e-mail de boas vindas
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem Vindo!", "Sua assinatura foi criada!");

            //Retornar informações
            return(new CommandResult(true, "Assinatura realizada com sucesso!"));
        }
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            // Fail Fast Validation
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura!!!"));
            }

            // Verificar se documento já está cadatrado
            if (_studentRepository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este documento já está em uso!!!");
            }

            // Verificar se os emails estão cadastrados
            if (_studentRepository.DocumentExists(command.Email))
            {
                AddNotification("Email", "Este Email já está em uso!!!");
            }

            // Gravar os VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var adress   = new Adress(command.Street, command.Number, command.Neighborhood,
                                      command.City, command.State, command.Country, command.ZipCode);

            // Gerar as entidades
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate,
                                                 command.ExpireDate, command.Total, command.TotalPaid, email, command.Payer,
                                                 new Document(command.PayerDocument, command.PayerDocumentType), adress);

            // Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            // Agrupar as validações
            AddNotifications(name, email, document, adress, student, subscription, payment);

            // Checar as notificações
            if (Invalid)
            {
                new CommandResult(false, "Não foi possível realizar sua assinatura!!!");
            }
            // Salvar as informações
            _studentRepository.CreateSubscription(student);

            // Enviar email de boas vindas
            _emailService.SendEmail(student.Name.ToString(),
                                    student.Email.Adress, "Bem-vindo ao PaymentContext!",
                                    "Pagamento Efetuado! R$100.00");

            // Retornar as informações
            new CommandResult(true, "Assinatura realizada com sucesso!!!");
        }
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            //Fail Fast validations
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            //Verificar se documento já esta cadastrado
            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Documents", "Este CPF já se encontra cadastrado");
            }
            //Verificar se email já esta cadastrado
            if (_repository.DocumentExists(command.Email))
            {
                AddNotification("Documents", "Este E-mail já se encontra cadastrado");
            }
            //Gerar VO
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.State, command.Country, command.ZipCode);

            //Gerar entidades
            var student      = new Student(name, document, email, address);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode,
                                                 command.BoletoNumber,
                                                 command.PaidDate,
                                                 command.ExipreDate,
                                                 command.Total,
                                                 command.TotalPaid,
                                                 new Document(command.OwnerDocument, command.OwnerType),
                                                 command.Owner,
                                                 address,
                                                 email);

            //Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscritpion(subscription);
            //Aplicar Validações
            AddNotifications(name, document, email, address, student, subscription, payment);

            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            //Salvar Informações
            _repository.CreateSubscrption(student);
            //Enviar E-mail
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao Site", "Sua Assinatura foi criada");

            return(new CommandResult(true, "Assinatura Realizada com sucesso"));
        }
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            //Fail Fast Validation

            if (!command.Validate())
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possivel realizar sua assinatura."));
            }

            if (_studentRepository.DocumentExistis(command.DocumentNumber))
            {
                AddNotification("Document", "CPF já em uso.");
            }

            if (_studentRepository.EmailExists(command.Email))
            {
                AddNotification("Email", "E-mail já em uso.");
            }

            if (command.Valid)
            {
                var name     = new Name(command.FirstName, command.LastName);
                var document = new Document(command.DocumentNumber, EDocumentType.CPF);
                var email    = new Email(command.Email);
                var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

                var student      = new Student(name, document, email);
                var subscription = new Subscription(DateTime.Now.AddMonths(1));
                var payment      = new BoletoPayment(
                    command.BarCode,
                    command.BoletoNumber,
                    command.PaidDate,
                    command.ExpireDate,
                    command.Total,
                    command.TotalPaid,
                    address,
                    new Document(command.PayerDocument, command.PayerDocumentType),
                    command.Payer,
                    email
                    );

                //Relacionamentos
                subscription.AddPayment(payment);
                student.AddSubscription(subscription);

                AddNotifications(name, document, email, address, student, subscription, payment);

                if (Valid)
                {
                    _studentRepository.CreateSubscription(student);
                    _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem Vindo", "Assinatura criada!");
                    return(new CommandResult(true, "Assinatura realizada com sucesso"));
                }
            }
            return(new CommandResult(false, "Não foi possivel realizar sua assinatura."));
        }
Пример #12
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            command.Validate();

            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar seu cadastro"));
            }

            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF já está em uso");
            }

            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "Este Email já está em uso");
            }

            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighbourhood, command.City, command.State, command.Country, command.ZipCode);

            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddDays(30));
            var payment      = new BoletoPayment(
                command.BarCode,
                command.BoletoNumber,
                command.PaidDate,
                command.ExpireDate,
                command.Total,
                command.TotalPaid,
                command.Payer,
                new Document(command.PayerDocument, command.PayerDocumentType),
                address,
                email
                );

            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            AddNotifications(name, document, email, address, student, subscription, payment);

            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            _repository.CreateSubscription(student);

            _emailService.Send(student.Name.ToString(), student.Email.Address, "Welcome", "Welcome");

            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            // Fail fast validations
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Subscription were not created"));
            }

            // Validates if Document exists
            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "This CPF is already in use");
            }

            // Validates if Email exists
            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "This E-mail is already in use");
            }

            // Create VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            // Create Entities
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid,
                                                 command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, new Email(command.PayerEmail));

            // Relationships
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            // Aggregate notifications
            AddNotifications(name, document, email, address, subscription, student, payment);

            // Check notifications
            if (Invalid)
            {
                return(new CommandResult(false, "It was not possible to create your subscription"));
            }

            // Save information
            _repository.CreateSubscription(student);

            // Send email
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Welcome to this site", "Subscription created successfully");

            // Returns
            return(new CommandResult(true, "Subscription created successfully"));
        }
Пример #14
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            // Fast validation
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Invalid paramters"));
            }

            // Verificar documentos cadastrados
            if (_repository.DocumentExists(command.PayerDocument))
            {
                AddNotification("Document", "Current document already exists");
            }

            // Verificar se email está cadastrados
            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "Current email already exists");
            }

            // Gerar os VDs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.PayerDocument, command.PayerDocumentType);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            // Gerar as entidades
            var studant      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddDays(30));
            var payment      = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.PayerDocument, document, address, email);

            // Relacionamentos
            subscription.AddPayment(payment);
            studant.AddSubscription(subscription);

            // agrupar as validações
            AddNotifications(document, email, address, address, studant, subscription, payment);

            // Checar as validações
            if (Invalid)
            {
                return(new CommandResult(false, "Invalid parameters"));
            }

            // Salvar as informações
            _repository.CreateSubscription(studant);

            // Enviar email de boas vindas
            _emailService.Send(studant.Name.ToString(), studant.Email.Address, "Bem-vindo", "Body");

            // Retornar informações
            return(new CommandResult(true, "Success in signature"));
        }
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            //Fail Fast Validation
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar a assinatura."));
            }

            //Verificar se documento já está cadastrado
            if (_studentRepository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF já existe.");
            }


            //Varificar se E-mail já está cadastrado
            if (_studentRepository.EmailExists(command.Email))
            {
                AddNotification("Email", "Este email já existe.");
            }

            //Gerar VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.City, command.State, command.Country, command.ZipCode);

            //Gerar Entidades
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, new Document(command.PayerDocument, command.PayerDocumentType), command.Payer, address, email);

            //Relacionamentos
            subscription.AddPayments(payment);
            student.AddSubscription(subscription);

            //Aplicar validações
            AddNotifications(name, document, email, address, student, subscription, payment);

            //Check notificações
            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possível realizar a assinatura."));
            }

            //Salvar as informações
            _studentRepository.CreateSubscription(student);

            //Enviar email de boas vindas
            _emailService.Send(name.ToString(), student.Email.Address, "Assinatura realizada com sucesso", "");

            return(new CommandResult(true, "Assinatura realizada com sucesso."));
        }
Пример #16
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand commad)
        {
            //validações
            commad.validate();
            if (commad.Invalid)
            {
                AddNotifications(commad);
                return(new CommandResult(false, "não foi possivel realiar seu cadastro"));
            }

            if (_repository.DocumentExist(commad.Document))
            {
                AddNotification("Documento", "Este Documento já Existe");
            }

            if (_repository.EmailExist(commad.Email))
            {
                AddNotification("Email", "Este email já esta em uso");
            }

            //gerar os VOs
            var document = new Document(commad.Document, EDocumentType.CPF);
            var nome     = new Name(commad.FistName, commad.LastName);
            var email    = new Email(commad.Email);
            var adrress  = new Address(commad.Street, commad.Number, commad.Neighborhood, commad.City, "Rj", "Niteroi", "123456");

            //gerar as entidaes
            var student      = new Student(nome, document, email, adrress);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(commad.BarCode, commad.BoletoNumber,
                                                 commad.PaidDate, commad.ExpireDate, commad.Total,
                                                 commad.TotalPaid, commad.Payer, new Document(commad.PayerDocument,
                                                                                              commad.PayerDocumentType), adrress, email);

            //Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            //agrupar as validações
            AddNotifications(nome, document, email, adrress, student, subscription, payment);

            //Checar notificações
            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possivel validar sua assinatura"));
            }

            //salvar as informações
            _repository.CreateSubscription(student);

            //enviar emai de boas vindas

            // retorna informações
            return(new CommandResult(true, "Usuario cadastrado com sucesso"));
        }
Пример #17
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            //Fail Fast Validations
            command.Validate();

            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Falha no cadastro"));
            }

            //Verificar se o dominio já está cadastrado
            if (_studentRepository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF já está em uso");
            }

            //Verificar se E-mail já está cadastrado
            if (_studentRepository.DocumentExists(command.Email))
            {
                AddNotification("Email", "Este Email já está em uso");
            }

            //Gerar os VOs
            var name         = new Name(command.FirstName, command.LastName);
            var document     = new Document(command.Document, EDocumentType.CPF);
            var email        = new Email(command.Document);
            var address      = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total,
                                                 command.TotalPaid, new Document(command.Number, command.Type), command.Payer, address, email);

            //Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            //Agrupar as notificaçõs
            AddNotifications(name, document, email, address, student, subscription, payment);

            //Checar as Notificações
            if (Invalid)
            {
                return(new CommandResult(false, "Falha na sua assinatura"));
            }

            //Salvar as informações
            _studentRepository.CreateSubscription(student);

            //Enviar E-mail de boas vindas
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao Sistema", "Assinatura criada");

            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }
        public static BoletoPayment BoletoTransactionRequest()
        {
            var boletoTransaction = new BoletoPayment
            {
                Amount   = 15057,
                Provider = ProviderEnum.Bradesco,
                Country  = "BRA",
                Currency = "BRL"
            };

            return(boletoTransaction);
        }
Пример #19
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            // Fail Fast Validation
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possivel realizar seu cadastro"));
            }

            //Verify whether document is already registred
            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF ja esta em uso");
            }

            //Verify whether eamil is already registred
            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "Este Email ja esta em uso");
            }

            //Generate VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            //Generate Entities
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode, command.BoletoNumber,
                                                 command.PaidDate, command.ExpireDate, command.Total,
                                                 command.TotalPaid, command.Payer,
                                                 new Document(command.PaymentNumber, command.PayerDocumentType),
                                                 address, email);

            //Apply Relationship
            subscription.AddPayment(payment);
            student.AddSubcription(subscription);

            //Group Validation
            AddNotifications(name, document, email, address, student, subscription, payment);

            //Save information
            _repository.CreateSubscription(student);

            //Send Welcome E-mail
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao guilherme.io", "Sua assinatura foi criada");

            //Return information
            return(new CommandResult(true, "Assinatura realizada com sucesso."));
        }
Пример #20
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Subscription register failed"));
            }

            if (_studentRepository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Document already in use");
            }

            if (_studentRepository.EmailExists(command.Email))
            {
                AddNotification("Email", "E-mail already in use");
            }

            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);

            var address = new Address(command.Street, command.Number, command.Neighborhood,
                                      command.City, command.State, command.Country, command.ZipCode);

            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.PaidDate,
                                                 command.ExpireDate,
                                                 command.Total,
                                                 command.TotalPaid,
                                                 command.Payer,
                                                 new Document(command.PayerDocument, command.PayerDocumentType = EDocumentType.CPF),
                                                 address,
                                                 email,
                                                 command.BarCode,
                                                 command.BoletoNumber);

            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            AddNotifications(name, document, email, address, student, subscription, payment);

            _studentRepository.CreateSubscription(student);

            _emailService.Send(student.Name.ToString(),
                               student.Email.Address,
                               $"Welcome {student.Name.ToString()}!",
                               "Your subscription has been approved. Go ahead and create your study plan.");

            return(new CommandResult(true, "Subscription successful added"));
        }
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }
            // Verificar se documento já estpa cadastrado
            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "CPF já utilizado");
            }

            // Verificar se E-mail já está cadastrado
            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "CPF já utilizado");
            }

            // GErar VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.State, command.Country, command.ZipCode);

            // Gerar Entidades
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(
                command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate,
                command.Total, command.TotalPaid, command.Payer,
                new Document(command.PayerDocument, command.PayerDocumentType),
                address, email
                );

            //Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            // Agrupar Validações
            AddNotifications(name, document, email, address, student, subscription, payment);

            // Salvar informações
            _repository.CreateSubscription(student);

            // Enviar e-mail de boas vindas
            _emailService.Send(student.Name.ToString(), student.Email.Address, "welcome", "ass ok");
            //Retornar informacoes

            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }
Пример #22
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            //Fail Fast validations
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            if (_repository.DocumentExists(command.Document))
            {
                AddNotifications(command);
                return(new CommandResult(false, "CPF já está em uso"));
            }

            if (_repository.EmailExists(command.Email))
            {
                AddNotifications(command);
                return(new CommandResult(false, "Email ja está em uso"));
            }

            //VOS
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentoType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            //Entidades
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, address, new Document(command.PayerDocument, command.PayerDocumentType), command.Payer, email);

            //Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            //Agrupar validacoes
            AddNotifications(name, document, email, address, student, subscription, payment);

            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possivel realizar sua assinatura"));
            }

            //Salvar as informacoes
            _repository.CreateSubscription(student);

            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao curso", "Sua Assinatura foi criada!");

            return(new CommandResult(true, "Assinatura realizada com sucesso!"));
        }
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "não foi possível realizar seu cadastro"));
            }

            //verificar se o documento já existe
            if (_repository.DocumentExists(command.Document))
            {
                AddNotifications(command);
                return(new CommandResult(false, "já existe um cadastro com o documento informado"));
            }

            //verificar se email já existe
            if (_repository.EmailExists(command.Email))
            {
                AddNotifications(command);
                return(new CommandResult(false, "já existe um cadastro com o e-mail informado"));
            }

            //gerar vo's
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            //gerar entidades
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, address,
                                                 new Document(command.PayerDocument, command.PayerDocumentType), command.Payer, email);

            //relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            //aplicar validações
            AddNotifications(name, document, email, address, student, subscription, payment);

            //salvar informações
            _repository.CreateSubscription(student);

            //Enviar email de boas vindas
            _emailService.Send(student.Name.ToString(), student.Email.Address, "bem vindo ao serviceName", "Sua assinatura foi criada!");

            //retornar informações
            return(new CommandResult(true, "Assinatura realizada com sucesso!"));
        }
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            //Fast Validations
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Subscription not confirmed"));
            }

            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Invalid CPF");
            }

            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "Invalid Email");
            }

            //Create VOs
            var name    = new Name(command.FirstName, command.LastName);
            var doc     = new Document(command.Document, EDocumentType.CPF);
            var email   = new Email(command.Email);
            var address = new Address(command.ZipCode, command.Street, command.Number, command.Complement, command.District, command.City, command.State, command.Country);

            //Create objects
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var customer     = new Customer(name, doc, email);
            var payment      = new BoletoPayment(command.Barcode, command.BoletoNumber, "", command.PaidDate, command.ExpireDate, new Document(command.OwnerDocument, command.OwnerDocumentType), email, command.Owner, address, command.Total, command.TotalPaid);

            //Add Subscription
            subscription.AddPayment(payment);
            customer.AddSubscription(subscription);

            //Check  Validations
            AddNotifications(name, doc, email, customer, address, subscription, payment);

            if (Invalid)
            {
                return(new CommandResult(false, "Signature can not be updated"));
            }

            //Save Customer
            _repository.CreateSubscription(customer);

            //Send email
            _emailService.Send(customer.Name.ToString(), customer.Email.Address, "Welcome to Music Store!", "Your signature has been created");

            return(new CommandResult(true, "Subscription created successfully"));
        }
Пример #25
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível efetuar seu cadastro"));
            }

            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Esse CPF já está em uso");
            }
            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "Esse email já está em uso");
            }

            var name         = new Name(command.FirstName, command.LastName);
            var document     = new Document(command.Document, EDocumentType.CPF);
            var email        = new Email(command.Email);
            var address      = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(
                command.BarCode,
                command.BoletoNumber,
                command.PaidDate,
                command.ExpireDate,
                command.Total,
                command.TotalPaid,
                command.Payer,
                new Document(command.PayerDocument, command.PayerDocumentType),
                address,
                email
                );

            // Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            // Agrupar as Validações
            AddNotifications(name, document, email, address, student, subscription, payment);

            // Enviar E-mail de boas vindas
            _emailService.Send(student.Name.ToString(), student.Email.Address, "bem vindo ao balta.io", "Sua assinatura foi criada");

            // Retornar informações
            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            if (_repository.DocumentExist(command.Document))
            {
                AddNotification("Document", "Este CPF já está em uso");
            }

            if (_repository.EmailExist(command.Email))
            {
                AddNotification("Email", "Este e-mail já está em uso");
            }

            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            var student = new Student(name, document, email);

            var subscription = new Subscription(DateTime.Now.AddMonths(1));

            var payment = new BoletoPayment(
                command.BardCode,
                command.BoletoNumber,
                new Email(command.PayerEmail),
                command.PaidDate,
                command.ExpireDate,
                command.Total,
                command.TotalPaid,
                command.Payer,
                new Document(command.PayerDocument, command.PayerDocumentType),
                address
                );

            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            AddNotifications(name, document, email, address, student, subscription, payment);

            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possivel realizar a sua assinatura."));
            }

            _repository.CreateSubscription(student);

            _emailService.Send(student.Name.FirstName, student.Email.Address, "Bem-vindo ao cursos dev", "Sua assinatura foi criada com sucesso.");

            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }
Пример #27
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResults(false, "Não foi possivel realizar a assinatura"));
            }
            //valida se o documento ja esta dentro da base
            if (_studentRepository.DocumentExists(command.Document))
            {
                return(new CommandResults(false, "Ester CPF, ja se encontra em uso."));
            }
            //valida se o Email ja esta dentro da base
            if (_studentRepository.EmailExists(command.Email))
            {
                return(new CommandResults(false, "Ester email, ja se encontra em uso."));
            }
            //Gerar Vo
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EnumDocumentType.Cpf);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);
            //Gerar as entidades

            var student      = new Student(name, document, email, address);
            var subscription = new Subscription(true);
            var payment      = new BoletoPayment(command.Barcode, command.BoletoNumber, command.PaidDate, null,
                                                 command.ExpireDate, command.Total, command.TotalPaid, address, document, command.Owner, email);

            //Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            //Agrupar as informações
            AddNotifications(name, document, email, address, student, subscription, payment);

            if (Invalid)
            {
                return(new CommandResults(false, "Não foi possivel realizar sua asinatura"));
            }
            //salvar as informaçoes
            _studentRepository.CreateSubscription(student);

            //Envia Email de boas vindas
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Assinatura realizada com sucesso!");

            //_studentRepository.CreateSubscription()
            return(new CommandResults(true, "Assinatura realizada com sucesso!"));
        }
Пример #28
0
        public ICommandResult Handle(CreateBoletoSubcriptionCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura."));
            }

            //VERIFICAR SE DOCUMENTO JÁ ESTÁ CADASTRADO
            if (_studentRepository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Esse CPF já está incluso.");
            }

            //VERIFICAR SE E-MAIL JÁ ESTÁ CADASTRADO
            if (_studentRepository.EmailExists(command.Email))
            {
                AddNotification("Email", "Esse e-mail já está incluso.");
            }

            //GERAR OS VOS
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);



            //GERAR AS ENTIDADES
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, email);

            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            AddNotifications(name, document, email, address, student, subscription, payment);
            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possível realizar a sua assinatura."));
            }

            _studentRepository.CreateSubcription(student);

            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao Fabiostefani.io", "Sua assinatura foi criada");

            return(new CommandResult(true, "Assinatura realizada com sucesso."));
        }
Пример #29
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            //Verificar se documento está cadastrado
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura."));
            }

            /*
             * // Verificar se Documento já está cadastrado.
             * if(_repository.DocumentExists(command.Document))
             *  AddNotification("Document","Este CPF já está em uso");
             *
             * // Email ja cadastrado
             * if(_repository.EmailExists(command.Email))
             *  AddNotification("Email","Este Email já está em uso");
             */

            // Gerrar os VOs

            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);;
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);
            var email    = new Email(command.Email);

            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate,
                                                 command.ExpireDate, command.Total, command.TotalPaid,
                                                 new Document(command.PayerDocument, command.PayerDocumentType), command.Payer, address, email);

            // Relacionamentos

            subscription.AddPayment(payment);
            student.AddSubscription(subscription);


            _repository.CreateSubscription(student);

            _emailService.Send(student.name.ToString(), student.Email.Address, "bem vindo", "Sua assinatura foi criada");

            //AddNotifications(new Contract());


            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possivel realizar sua assinatura"));
            }

            if (_studentRepository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF já está em uso");
            }

            if (_studentRepository.DocumentExists(command.EnderecoEmail))
            {
                AddNotification("Document", "Este CPF já está em uso");
            }

            var _name         = new Name(command.FirstName, command.LastName);
            var _document     = new Document(command.Document, Domain.Enum.EDocumentType.CPF);
            var _email        = new Email(command.EnderecoEmail);
            var _address      = new Address(command.Rua, command.Bairro, command.Cidade, command.Estado, command.Pais, command.Complemento, command.Numero, command.CEP);
            var _student      = new Student(_name, _document, _email);
            var _subscription = new Subscription(DateTime.Now.AddMonths(1));

            var paypalPayment = new BoletoPayment(
                command.BarCode,
                command.BoletoNumber,
                command.PaidDate,
                command.ExpireDate,
                command.Total,
                command.TotalPaid,
                command.Owner,
                new Document(command.PayerDocument.Number, command.PayerDocumentType),
                _address,
                _email
                );

            _subscription.AddPayments(paypalPayment);
            _student.AddSubscription(_subscription);
            AddNotifications(_name, _document, _email, _address, _student, _subscription, paypalPayment);

            _studentRepository.CreateSubscription(_student);
            _emailService.Send(_student.Name.ToString(), _student.Email.EnderecoEmail, "Bem vindo", "Sua assinatura foi criada");
            AddNotifications(new Contract());
            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }