public void ShouldReturnSuccessWhenStudentHasAnActiveSubscriptionAndPaymentMethod()
        {
            _Student      = new Student(_Name, _Email, _Address, _Document);
            _Subscription = new Subscription(DateTime.Now);
            var payment = new Boleto(DateTime.Now, DateTime.Now.AddDays(3), new Document("0000000000", EDocumentType.CPF), 100, 100, "079909090797090");

            _Subscription.AddPaymentMethod(payment);
            _Student.AddSubscription(_Subscription);
            Assert.IsTrue(_Student.Valid);
        }
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            // fail fast validation
            command.Validate();

            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "It's not possible to realize your subscribe."));
            }

            // verify if the document is already exists (go in database)
            if (_Repository.DocumentExists(command.PayerDocument))
            {
                AddNotifications(command);
                return(new CommandResult(false, "CPF already exists."));
            }


            // verify if e-mail is already registered

            if (_Repository.EmailExists(command.PayerEmailAddress))
            {
                AddNotifications(command);
                return(new CommandResult(false, "Email already exists."));
            }

            // generate VO's
            var name     = new Name(command.FirstName, command.LastName);
            var email    = new Email(command.PayerEmailAddress);
            var address  = new Address(command.PublicArea, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);
            var document = new Document(command.PayerDocument, command.PayerDocumentType);

            // generate entities
            var student      = new Student(name, email, address, document);
            var subscription = new Subscription(command.SubscriptionExpireDate);
            var payment      = new Boleto(
                command.PaidDate,
                command.ExpireDate,
                new Document(command.PayerDocument, command.PayerDocumentType),
                command.Total,
                command.TotalPaid,
                command.BarCode
                );

            // relationships
            subscription.AddPaymentMethod(payment);
            student.AddSubscription(subscription);

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

            // validate notifications
            if (Invalid)
            {
                return(new CommandResult(false, "It's not possible to finalize your subscription."));
            }

            // save informations
            _Repository.CreateSubscription(student);

            // send welcome email
            _EmailService.send(student.ToString(), student.Email.Address, "Congratulations for subscribing", "Welcome!");

            // return infos
            return(new CommandResult(true, "Subscribe done with success"));
        }