示例#1
0
        public void Text(Participant recipient, string message)
        {
            TwilioClient.Init(_twilioAccountSid, _twilioToken);
            List <PhoneNumber> numberList = new DatabaseServices().GetParticipants()
                                            .Select(x => new PhoneNumber(x.Phone))
                                            .ToList();

            Parallel.ForEach(numberList, (p) =>
            {
                var sms = MessageResource.Create(p, from: _twilioFrom, body: message);
            });
        }
示例#2
0
        public void Call()
        {
            var instructionsXml = ConfigurationManager.AppSettings["TwilioInstructionsXML"];

            TwilioClient.Init(_twilioAccountSid, _twilioToken);
            List <PhoneNumber> numberList = new DatabaseServices().GetParticipants()
                                            .Select(x => new PhoneNumber(x.Phone))
                                            .ToList();

            Parallel.ForEach(numberList, (p) =>
            {
                var call = CallResource.Create(p, _twilioFrom, url: new Uri(instructionsXml), method: HttpMethod.Get);
            });
        }
示例#3
0
        // here's an example of a tuple, and why I personally don't like them...
        public Tuple <Participant, Participant> GetMaleFemaleRandomPair()
        {
            List <Participant> allParticipants = new DatabaseServices().GetParticipants();
            var randomFemale = allParticipants
                               .Where(x => x.Gender == TypeOfGender.Female)
                               .OrderBy(x => Guid.NewGuid())
                               .First();
            var randomMale = allParticipants
                             .Where(x => x.Gender == TypeOfGender.Male)
                             .OrderBy(x => Guid.NewGuid())
                             .First();

            return(new Tuple <Participant, Participant>(randomMale, randomFemale));
        }
示例#4
0
        public void SendMail()
        {
            var        participantList = new DatabaseServices().GetParticipants();
            SmtpClient postman         = new SmtpClient(_smtpServer, _smtpPort);

            postman.EnableSsl   = true;
            postman.Credentials = new System.Net.NetworkCredential(_smtpUsername, _smtpPassword);
            foreach (var p in participantList)
            {
                MailMessage email = new MailMessage(new MailAddress(_mailFrom, "Empower Course"), new MailAddress(p.Email))
                {
                    Subject    = "Hi there!",
                    Body       = "This is just a friendly reminder that Winston-Salem can code circles around you (just kidding).  Have a great evening!",
                    IsBodyHtml = true
                };
                postman.Send(email);
            }
        }