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

            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possivel realizar sua assinatura!"));
            }
            AddNotifications(new Contract());
            //Verificar se Documento já esta cadastrado

            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF já está em uso");
            }
            //Verificar se E-mail já esta cadastro
            if (_repository.EmailExists(command.Document))
            {
                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.Address);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.County, 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.ToString(), 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 email de boas vindas

            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao balta.io", "Sua assinatura foi criada");
            //Retornar informaçoes

            return(new CommandResult(true, "Assinatura realizada com sucesso!"));
        }
示例#2
0
        /// <summary>
        /// Generates an e-mail to alert Mardix personnel that a network file write has failed due to the file path being too long
        /// </summary>
        /// <param name="filePath">The file path</param>
        private void EmailFilePathTooLongWarning(string filePath)
        {
            // Build up subject line
            var subject = Globalisation.Emails.FilePathTooLongSubject;

            // Build up subject body
            var body = Globalisation.Emails.FilePathTooLongBody.Replace(EmailServices.PlaceHolders.FilePath, filePath)
                       .Replace(EmailServices.PlaceHolders.FileWriteDateTime, SystemTime.UtcNow().ToLongDateAndTimeString());

            // Build up list of recipients
            var emailTo = new List <string>
            {
                _configurationManager.ServiceDepartment.EmailReportTeam,
                "*****@*****.**",
                "*****@*****.**"
            };

            try
            {
                emailTo.ForEach(e => _emailServices.Send(e, subject, body));
            }
            catch (Exception ex)
            {
                throw new SmtpException(ex.Message);
            }
        }
示例#3
0
        public string AddClient(Client client)
        {
            if (!client.IsValid())
            {
                return("Invalid data !");
            }

            _clienteRepository.AddClient(client);

            _emailService.Send("*****@*****.**", client.Email, "Welcome !", "You are registered");
            return("Cliente registered with success !");
        }
示例#4
0
        public void SendVerificationEmail(User user, string verificationCode)
        {
            string message;

            message = $@"<h3>Thank you for registering. Your verification code is: <br></h3>
                             <h1>{verificationCode}</h1>";

            _emailServices.Send(
                to: user.Email,
                subject: "Verify Your Email",
                html: message
                );
        }
示例#5
0
        private string Add(ICustomer customer)
        {
            if (!customer.IsValid())
            {
                return("Customer data is invalid!");
            }

            _customerRepository.Add(customer);

            return(_emailServices.Send(customer.Email, "Welcome", "Congratulations! You are registered.")
                ? "Customer successfully registered!"
                : "Customer successfully registered, but email was not sent! Review the SMTP settings in configuration file.");
        }
示例#6
0
        public ICommandResult Handle(CreateCustomerCommand command)
        {
            //Verificar se o CPF já existe na base
            if (_customerRepository.CheckDocumentExists(command.Document))
            {
                AddNotification("Document", "Esse CPF já está cadastrado.");
            }

            //Verificar se o E-mail já existe na base
            if (_customerRepository.CheckEmailExists(command.Email))
            {
                AddNotification("Email", "Esse E-mail já está em uso.");
            }

            //Criar os VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document);
            var email    = new Email(command.Email);

            //Criar a entidade
            var customer = new Customer(name, document, email, command.Phone);

            //Validar Entidade e VOs
            AddNotifications(name.Notifications);
            AddNotifications(document.Notifications);
            AddNotifications(email.Notifications);
            AddNotifications(customer.Notifications);

            if (Invalid) // Propriedade do Flunt (Se tiver notificações é inválido)
            {
                return(new ResponseCommand(false, "Verifique as Notificações", Notifications));
            }

            //Persistir o Cliente
            _customerRepository.Save(customer);

            //Enviar um E-mail de boas vindas.
            _emailServices.Send(email.Address, "*****@*****.**", "Seja em vindo", "Corpo do email");


            //Retornar o resultado para tela
            return(new ResponseCommand(
                       true,                              //Success
                       "Cliente cadastrado com sucesso.", //Message
                       new {                              //Data
                Id = customer.Id,
                Name = name,
                Email = email
            }));
        }
示例#7
0
        public string AddClient(Client client)
        {
            if (!client.IsValid())
            {
                return(Properties.Resources.InvalidClient);
            }

            _clientRepository.AddClient(client);
            _emailServices.Send(
                "*****@*****.**",
                client.Email,
                Properties.Resources.ClientWelcome,
                Properties.Resources.CongratulationsRegister);

            return(string.Format(Properties.Resources.AddClientSuccess, client.Name));
        }
示例#8
0
        public string AddCustomer(Customer customer)
        {
            if (!customer.Validate())
            {
                return("Invalid data");
            }

            _customerRepository.AddCustomer(customer);

            _emailServices.Send(
                "*****@*****.**",
                customer.Email.Address,
                "Welcome",
                "Congratulations you are registered"
                );

            return("Customer successfully registered");
        }
示例#9
0
        public string AddClient(Client client)
        {
            if (!client.IsValid())
            {
                return("Invalid data");
            }

            //Repository coupling
            // var repo = new ClientRepository();
            // repo.AddClient(client);
            _clientRepository.AddClient(client);

            //EmailServices coupling
            //EmailServices.Send("*****@*****.**", client.Email, "Welcome", "Congratulations!!!");
            _emailServices.Send("*****@*****.**", client.Email, "Welcome", "Congratulations!!!");

            return("Client ok");
        }
示例#10
0
        public ICommandResult Handle(CreateCustomerCommand command)
        {
            //Verificar se CPF ja existe na base
            if (_customerRepository.CheckDocument(command.Document))
            {
                AddNotification("Document", "Este CPF já existe!");
            }

            //Verificar se email ja existe na base
            if (_customerRepository.CheckEmail(command.Email))
            {
                AddNotification("Email", "Email já existe!");
            }

            if (Invalid)
            {
                return(null);
            }

            //Criar VOs
            var name     = new Name(command.FirstName, command.LestName);
            var document = new Document(command.Document);
            var email    = new Email(command.Email);

            // Criar entidade
            var customer = new Customer(name, document, email, command.Phone);

            //Validar VOs
            AddNotifications(name.Notifications);
            AddNotifications(document.Notifications);
            AddNotifications(email.Notifications);
            AddNotifications(customer.Notifications);

            //Persistir cliente
            _customerRepository.Save(customer);

            //Enviar email de boas vindas
            _emailServices.Send(email.Adress, "*****@*****.**", "Bem vindo", "Seja bem vindo!");

            return(new CreatCustomerCommandResult(customer.Id, name.ToString(), email.Adress));
        }