예제 #1
0
        /// <summary>
        /// Send email to multiple receipts
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="subject"></param>
        /// <param name="htmlMessage"></param>
        /// <param name="recipients"></param>
        /// <returns></returns>
        public Task SendBulkEmailAsync(string[] emails, string subject, string htmlMessage)
        {
            var client = new SmtpClient(host, port)
            {
                Credentials = new NetworkCredential(userName, password),
                EnableSsl   = enableSSL
            };

            MailMessage mailMessage = new MailMessage();

            mailMessage.Body       = htmlMessage;
            mailMessage.IsBodyHtml = true;
            mailMessage.Subject    = subject;

            foreach (string emailAdress in emails)
            {
                if (DataValidationManager.CheckIsValiedEmailAddress(emailAdress))
                {
                    mailMessage.To.Add(emailAdress);
                }
            }


            return(client.SendMailAsync(mailMessage));;
        }
예제 #2
0
        public void CheckAdress_WhenUserDataIsInvalid_ShouldReturnErrorWithMessage(string adress)
        {
            //Arrange
            (bool, string)expected = (false, UserMessages.InvalidAddressFormat);

            //Act
            var result = DataValidationManager.CheckAddress(adress);

            //Assert
            Assert.Equal(expected, result);
        }
예제 #3
0
        public void CheckUserName_WhenUserDataIsInvalid_ShouldReturnErrorWithMessage(string sentence)
        {
            //Arrange
            (bool, string)expected = (false, UserMessages.InvalidFirstName);

            //Act
            var result = DataValidationManager.CheckFirstName(sentence);

            //Assert
            Assert.Equal(expected, result);
        }
예제 #4
0
        public void CheckEmail_WhenUserEmailIsInvalid_ShouldReturnErrorWithMessage()
        {
            //Arrange
            (bool, string)expected = (false, UserMessages.InvalidEmailFormat);
            string email = "test%test.com";

            //Act
            var result = DataValidationManager.CheckEmail(email);

            //Assert
            Assert.Equal(expected, result);
        }
예제 #5
0
        public void CheckAdress_WhenUserDataIsCorrect_ShouldReturnCorrectResult()
        {
            //Arrange
            (bool, string)expected = (true, string.Empty);
            string adress = "Koktajlowo 16";

            //Act
            var result = DataValidationManager.CheckAddress(adress);

            //Assert
            Assert.Equal(expected, result);
        }
예제 #6
0
        public void CheckUserName_WhenUserDataCorrect_ShouldReturnCorrectResult()
        {
            //Arrange
            (bool, string)expected = (true, string.Empty);
            string userName = "******";

            //Act
            var result = DataValidationManager.CheckFirstName(userName);

            //Assert
            Assert.Equal(expected, result);
        }
예제 #7
0
        public void CheckEmail_WhenUserEmailIsCorrect_ShouldReturnCorrectResult()
        {
            //Arrange
            (bool, string)expected = (true, string.Empty);
            string email = "*****@*****.**";

            //Act
            var result = DataValidationManager.CheckEmail(email);

            //Assert
            Assert.Equal(expected, result);
        }
예제 #8
0
        private void Confirm_Click(object sender, EventArgs e)
        {
            List <(bool, string)> validators = new List <(bool, string)>()
            {
                DataValidationManager.CheckEmail(EmailTextBox.Text),
                DataValidationManager.CheckFirstName(FirstNameTextBox.Text),
                DataValidationManager.CheckLastName(LastNameTextBox.Text),
                DataValidationManager.CheckAddress(AddressTextBox.Text),
            };

            foreach (var validator in validators)
            {
                if (!string.IsNullOrEmpty(validator.Item2))
                {
                    MessageBox.Show(validator.Item2, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                }
            }

            if (validators.TrueForAll(x => x.Item1))
            {
                var emailBody = string.Format(emailBodyFormat, AddressTextBox.Text, FirstNameTextBox.Text, LastNameTextBox.Text, NotesTextBox.Text);

                EmailSendStatus emailSendStatus = new EmailManager().SendEmail(EmailTextBox.Text, "Pizza Application Order", emailBody);

                if (emailSendStatus.SendSuccessfully)
                {
                    MessageBox.Show(UserMessages.EmailSended, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    AddHistoryRecordToDatabase();
                    UserActionHelpers.ClearAllTextBoxData();
                    Hide();
                    WindowsManagement.GetMainWindowInstance().Show();
                }
                else
                {
                    MessageBox.Show(UserMessages.EmailFailedToSend, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }