public void SendBlindSpotMail(EmailRequest emailRequest)
        {
            EmailTemplate mailtemplete = _mailTemplateAdapter.GetEmailTemplates(emailRequest.type);

            foreach (var coworker in emailRequest.coworkers)
            {
                try
                {
                    var mailBody = CreatMailBody(coworker, mailtemplete);
                    emailRequest.subject   = _subject;
                    emailRequest.emailbody = mailBody;
                    _email.SendEmail(coworker, mailBody, _subject);
                    emailRequest.status = "Success";
                    _mailTemplateAdapter.InsertEmailRequest(emailRequest);
                }
                catch (Exception)
                {
                    emailRequest.status = "Failed";
                    emailRequest.mailto = coworker;
                    _mailTemplateAdapter.InsertEmailRequest(emailRequest);
                }
            }
        }
示例#2
0
        public void GetEmailTemplates_ReturnsTemplate()
        {
            Dictionary <string, string> collection = new Dictionary <string, string>
            {
                { "body", "body" }, { "headerprefix", "hi" }, { "footer", "footer" }, { "subject", "hi" }
            };

            _mockEmailTemplate.Setup(p => p.GetRecords(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new BsonDocument(collection));

            var actual = _emailTemplateAdapter.GetEmailTemplates("");

            Assert.AreEqual("hi", actual.headerprefix);
        }