コード例 #1
0
ファイル: OrderService.cs プロジェクト: FlumpStudios/PlinxHub
        private async Task SendConfirmationEmails(
            string refNumber,
            string clientEmailAddress,
            string clientName)
        {
            EmailAddress clientRecip = new EmailAddress
            {
                Email = clientEmailAddress,
                Name  = clientName
            };

            EmailAddress BusinessRecip = new EmailAddress
            {
                Email = _appSettings.Value.Emailing.SenderAddress,
                Name  = _appSettings.Value.Emailing.SenderName
            };

            var clientTemplate = await _emailRepository.Get(EmailTemplateOptions.NewOrderAlert);

            var businessTemplate = await _emailRepository.Get(EmailTemplateOptions.OrderConfirmation);

            Email clientMessage = new Email
            {
                EmailTemplate = clientTemplate.ReplaceOrderNumber(refNumber),
                Recipients    = new List <EmailAddress>()
                {
                    clientRecip
                }
            };

            Email buinessMessage = new Email
            {
                EmailTemplate = businessTemplate.ReplaceOrderNumber(refNumber),
                Recipients    = new List <EmailAddress>()
                {
                    BusinessRecip
                }
            };

            await _emailService.Send(clientMessage);

            await _emailService.Send(buinessMessage);
        }
コード例 #2
0
 public IHttpActionResult Get()
 {
     try
     {
         var list    = new List <dynamic>();
         var records = _emailRepository.Get();
         foreach (var record in records)
         {
             var     xDocument = ProcessingData(record.Data);
             dynamic root      = new ExpandoObject();
             XmlToDynamic.Parse(root, xDocument.Elements().First());
             list.Add(root.root);
         }
         return(new CustomResponse(HttpStatusCode.OK, list));
     }
     catch (Exception ex)
     {
         return(new CustomResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
コード例 #3
0
        public async Task WhenGetEmails_ThenGetSuccessful()
        {
            //?Given
            var emailList = new List <Email>
            {
                new Email
                {
                    Id           = "1234",
                    UserName     = "******",
                    CreationTime = new DateTime()
                }
            };

            var emailEntity = new List <EmailEntity>();

            _mockService.Setup(x => x.Get <EmailEntity>(It.IsAny <string>()))
            .ReturnsAsync(emailEntity)
            .Verifiable();

            _mockMapper.Setup(x => x.Map <IEnumerable <Email> >(It.IsAny <IEnumerable <EmailEntity> >()))
            .Returns(emailList)
            .Verifiable();

            //?When
            var result = await _emailRepository.Get();

            //?Then
            Assert.NotNull(result);

            var actual   = result.ToList().FirstOrDefault();
            var expected = emailList.FirstOrDefault();

            Assert.Equal(expected.Id, actual.Id);
            Assert.Equal(expected.UserName, actual.UserName);
            Assert.Equal(expected.CreationTime, actual.CreationTime);

            _mockService.Verify();
            _mockMapper.Verify();
        }
コード例 #4
0
        public void SendEmail()
        {
            List <UserProfile> destEmails = _emailRepository.Get();

            destEmails.ForEach(item => _emailSender.SendEmail(_webDataScrapingService.GetDailySummary(), item.Email));
        }
コード例 #5
0
 public async Task <IEnumerable <Email> > Get()
 {
     return(await _repository.Get());
 }