Esempio n. 1
0
 public void TestAllHosts(Recipient sendTo)
 {
     _smtpMailHosts.AsParallel().ForAll(h =>
                                            {
                                                var testText = "Teste Mail From " + h.Key.Mail;
                                                h.Value.SendMail(testText,testText, new[] {sendTo});
                                            });
 }
        public void CanCreateNew()
        {
            using (var session = PersistenceHelper.OpenSession())
            {
                var repository = new RecipientRepository(session);
                var r = new Recipient {Email = "*****@*****.**", IsActive = true, Name = "Chalk"};
                repository.CreateOrUpdate(r);

                Assert.IsTrue(repository.GetActive().Count > 0);
                repository.Remove(r);
            }
        }
Esempio n. 3
0
        public JsonResult Subscrible(string name, string email)
        {
            var recipient = new Recipient {Email = email, Name = name, IsActive = true};
            using (var session = PersistenceHelper.OpenSession())
            {
                var repository = new RecipientRepository(session);
                var recipientGet = repository.GetByEmail(email);
                if (recipientGet == null)
                    repository.CreateOrUpdate(recipient);
                else
                {
                    recipientGet.IsActive = true;
                    repository.CreateOrUpdate(recipientGet);
                }
            }

            return Json(new { messageStatus = "OK", status = "Subscribled", recipient }, JsonRequestBehavior.AllowGet);
        }
Esempio n. 4
0
        private static void ImportRecipients()
        {
            Console.Clear();
            Console.WriteLine("Informe o caminho do arquivo csv");
            var path = Console.ReadLine();
            var file = new System.IO.StreamReader(path);

            while (!file.EndOfStream)
            {
                var data = file.ReadLine().Split(',');
                Console.WriteLine("Importando \"contato: {0} - Email: {1}\"".FormatWith(data[0], data[1]));
                var recipient = new Recipient {Name = data[0], Email = data[1], IsActive = true};
                using (var session = PersistenceHelper.OpenSession())
                {
                    var repository = new RecipientRepository(session);
                    repository.CreateOrUpdate(recipient);
                }
            }
            file.Close();
            Console.WriteLine("Importação conluida");
            Console.ReadKey();
        }