Example #1
0
 private static void AddEmail(string email, RegistrantDb registrantDb)
 {
     if (!string.IsNullOrEmpty(email))
     {
         registrantDb.Emails.Add(email);
     }
 }
Example #2
0
        public void SendRegistrationNotification(RegistrantDb registrant, string url)
        {
            var registrantDb = JsonSerializer.Serialize <RegistrantDb>(registrant);
            var client       = new HttpClient();

            _ = client.PostAsync(url, new StringContent(registrantDb, Encoding.UTF8, "application/json"));
        }
Example #3
0
        public void BuildRegistantModelTest_1_Email_1_Phone_check_phone()
        {
            var registrant = new RegistrantDb
            {
                Emails = new List <string> {
                    "*****@*****.**"
                },
                FirstName   = "Dick",
                LastName    = "Grayson",
                Sport       = "Track",
                IsVolunteer = false,
                ProgramName = "Woodbridge",
                SportId     = 8,
                ProgramId   = 11,
                Size        = "small",
            };

            registrant.Phones = new List <RegistrantPhone>();
            registrant.Phones.Add(new RegistrantPhone {
                CanText = true, Phone = "7035551212"
            });


            _worker = new RegistrantMessageWorker(registrant);
            var actual = _worker.BuildRegistrant();

            Assert.Equal(1, actual.RegistrantPhone.Count);
        }
Example #4
0
        public void BuildRegistantModelTest_medical_check_1_athlete_fields()
        {
            var registrant = new RegistrantDb
            {
                Emails = new List <string> {
                    "*****@*****.**"
                },
                FirstName   = "Dick",
                LastName    = "Grayson",
                Sport       = "Track",
                IsVolunteer = true,
                ProgramName = "Woodbridge",
                SportId     = 8,
                ProgramId   = 11,
                NickName    = "Robin",
                AthleteId   = 123
            };

            registrant.Phones = new List <RegistrantPhone>();
            registrant.Phones.Add(new RegistrantPhone {
                CanText = true, Phone = "7035551212"
            });
            registrant.Phones.Add(new RegistrantPhone {
                CanText = false, Phone = "2125551212"
            });
            registrant.Phones.Add(new RegistrantPhone {
                CanText = false, Phone = "3015551212"
            });
            registrant.Emails.Add("*****@*****.**");

            _worker = new RegistrantMessageWorker(registrant);
            var actual = _worker.BuildRegistrant();

            Assert.Equal(1, actual.RegisteredAthlete.Count);
        }
Example #5
0
        public async Task <HttpResponseMessage> GetRegistrationAthlete(RegistrantDb registrant, string url)
        {
            var registrantDb = JsonSerializer.Serialize <RegistrantDb>(registrant);
            var client       = new HttpClient();
            var athlete      = await client.PostAsync(url, new StringContent(registrantDb, Encoding.UTF8, "application/json"));

            return(athlete);
        }
Example #6
0
        public void BuildEmailFromTest_email_email_matches()
        {
            var registrant = new RegistrantDb {
                Sender = "*****@*****.**"
            };

            _worker = new RegistrantMessageWorker(_message, registrant);
            _worker.BuildEmailFrom();
            Assert.Equal(registrant.Sender, _message.From.Email);
        }
Example #7
0
        public void BuildEmailFromTest_no_email_email_default()
        {
            var registrant            = new RegistrantDb {
            };
            const string defaultEmail = "*****@*****.**";

            _worker = new RegistrantMessageWorker(_message, registrant);
            _worker.BuildEmailFrom();
            Assert.Equal(_message.From.Email, defaultEmail);
        }
Example #8
0
        public void BuildEmailMedicalToTest_No_Found_Email_email_matches()
        {
            var registrant = new RegistrantDb {
                Emails = new List <string> {
                    "*****@*****.**"
                }
            };

            _worker = new RegistrantMessageWorker(_message, registrant);
            _worker.BuildEmailMedicalTo();
            Assert.Equal("*****@*****.**", _message.Personalizations[0].Tos[0].Email);
        }
Example #9
0
        private static void AddPhone(string phone, string phoneType, bool canText, RegistrantDb registrantDb)
        {
            if (string.IsNullOrEmpty(phone))
            {
                return;
            }
            var registrantPhone = new RegistrantPhone {
                Phone = phone, PhoneType = phoneType, CanText = canText
            };

            registrantDb.Phones.Add(registrantPhone);
        }
Example #10
0
        public void BuildEmailCopyTest_from_eq_cc()
        {
            var registrant = new RegistrantDb {
                FirstName = "Dick", LastName = "Grayson", NickName = "Robin", Sport = "Track", ProgramName = "Gainesville", IsVolunteer = false, Sender = "*****@*****.**", AthleteId = 0
            };

            _message.From = new EmailAddress(registrant.Sender);
            _message.AddTo("*****@*****.**");
            _worker = new RegistrantMessageWorker(_message, registrant);
            _worker.BuildEmailCopy();
            Assert.Equal(registrant.Sender, _message.Personalizations[0].Ccs[0].Email);
        }
Example #11
0
        public void BuildEmailCopyTest_when_from_eq__to_no_cc()
        {
            var registrant = new RegistrantDb {
                FirstName = "Dick", LastName = "Grayson", NickName = "Robin", Sport = "Track", ProgramName = "Gainesville", IsVolunteer = true, Sender = "*****@*****.**"
            };

            _message.From = new EmailAddress(registrant.Sender);
            _message.AddTo(registrant.Sender);
            _worker = new RegistrantMessageWorker(_message, registrant);
            _worker.BuildEmailCopy();
            Assert.Null(_message.Personalizations[0].Ccs);
        }
Example #12
0
        public void BuildEmailToTest_2_Email_email_matches()
        {
            var registrant = new RegistrantDb {
                Emails = new List <string> {
                    "*****@*****.**", "*****@*****.**"
                }
            };

            _worker = new RegistrantMessageWorker(_message, registrant);
            _worker.BuildEmailTo();
            Assert.Equal(_message.Personalizations[0].Tos[0].Email, registrant.Emails[0]);
            Assert.Equal(_message.Personalizations[0].Tos[1].Email, registrant.Emails[1]);
        }
Example #13
0
        public void BuildPhoneListTest_1_phone_0_text_0_list()
        {
            var registrant = new RegistrantDb();

            registrant.Phones = new List <RegistrantPhone>();
            registrant.Phones.Add(new RegistrantPhone {
                CanText = false, Phone = "7035551212"
            });
            _worker = new RegistrantMessageWorker(registrant, "20255512121");
            List <string> actual = _worker.BuildPhoneList();

            Assert.Equal(0, actual.Count);
        }
Example #14
0
        public RegistrantMessageWorker(SendGridMessage message, RegistrantDb registrant)
        {
            _message            = message;
            _registrant         = registrant;
            _registrantSendGrid = new RegistrantSendGrid {
                Name = FormatName(), Sport = registrant.Sport
            };

            if (!string.IsNullOrEmpty(registrant.ProgramName))
            {
                _registrantSendGrid.Sport += " at " + registrant.ProgramName;
            }

            if (registrant.AthleteId > 0 && registrant.MedicalExpirationDate.HasValue)
            {
                _registrantSendGrid.MedicalExpirationDate = registrant.MedicalExpirationDate.Value.ToLongDateString();
            }
        }
Example #15
0
        public void BuildRegistantModelTest_2_Email_3_Phone_check_regrant_fields()
        {
            var registrant = new RegistrantDb
            {
                Emails = new List <string> {
                    "*****@*****.**"
                },
                FirstName   = "Dick",
                LastName    = "Grayson",
                Sport       = "Track",
                IsVolunteer = true,
                ProgramName = "Woodbridge",
                SportId     = 8,
                ProgramId   = 11,
                NickName    = "Robin"
            };

            registrant.Phones = new List <RegistrantPhone>();
            registrant.Phones.Add(new RegistrantPhone {
                CanText = true, Phone = "7035551212"
            });
            registrant.Phones.Add(new RegistrantPhone {
                CanText = false, Phone = "2125551212"
            });
            registrant.Phones.Add(new RegistrantPhone {
                CanText = false, Phone = "3015551212"
            });
            registrant.Emails.Add("*****@*****.**");

            _worker = new RegistrantMessageWorker(registrant);
            var actual = _worker.BuildRegistrant();

            Assert.Equal(registrant.FirstName, actual.FirstName);
            Assert.Equal(registrant.LastName, actual.LastName);
            Assert.Equal(0, actual.Id);
            Assert.Equal(registrant.IsVolunteer, actual.IsVolunteer);
            Assert.Equal(registrant.ProgramId, actual.ProgramId);
            Assert.Equal(registrant.Size, actual.Size);
            Assert.Equal(registrant.SportId, actual.SportId);
            Assert.Equal(registrant.NickName, actual.NickName);
            Assert.Equal(3, actual.RegistrantPhone.Count);
            Assert.Equal(2, actual.RegistrantEmail.Count);
        }
Example #16
0
        public void BuildPhoneListTest_3_phone_3_text_3_list()
        {
            var registrant = new RegistrantDb();

            registrant.Phones = new List <RegistrantPhone>();
            registrant.Phones.Add(new RegistrantPhone {
                CanText = true, Phone = "7035551212"
            });
            registrant.Phones.Add(new RegistrantPhone {
                CanText = true, Phone = "2125551212"
            });
            registrant.Phones.Add(new RegistrantPhone {
                CanText = true, Phone = "3015551212"
            });
            _worker = new RegistrantMessageWorker(registrant, "20255512121");
            List <string> actual = _worker.BuildPhoneList();

            Assert.Equal(3, actual.Count);
            Assert.Equal("+17035551212", actual[0]);
            Assert.Equal("+12125551212", actual[1]);
            Assert.Equal("+13015551212", actual[2]);
        }
Example #17
0
 public RegistrantMessageWorker(RegistrantDb registrant)
 {
     _registrant = registrant;
 }
Example #18
0
 public RegistrantMessageWorker(RegistrantDb registrant, string fromNumber)
 {
     _registrant = registrant;
     _fromNumber = fromNumber;
 }