예제 #1
0
        public async Task WhenGetEmails_ThenGetSuccessful()
        {
            //?Given
            var emailList = new List <Email>
            {
                new Email
                {
                    Id           = "1234",
                    UserName     = "******",
                    CreationTime = new DateTime()
                }
            };

            _mockRepository.Setup(x => x.Get())
            .ReturnsAsync(emailList)
            .Verifiable();

            //?When
            var result = await _emailManager.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);

            _mockRepository.Verify();
        }
예제 #2
0
        public async Task <ActionResult <IEnumerable <EmailModel> > > Get()
        {
            var emails = await _emailManager.Get();

            var emailsModel = _mapper.Map <IEnumerable <EmailModel> >(emails);

            return(Ok(emailsModel));
        }
예제 #3
0
        public void SendMessage(MessageFormat message)
        {
            DAL.EntityFramework.Tables.Email supportEmail = _email.Get();
            if (supportEmail == null)
            {
                return;
            }
            MailMessage mail = new MailMessage();

            mail.To.Add(message.Hedef);
            mail.From       = new MailAddress(supportEmail.EmailAddres);
            mail.Subject    = message.Baslik;
            mail.Body       = message.Icerik;
            mail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();

            smtp.Host = supportEmail.Host;
            smtp.Port = int.Parse(supportEmail.Port);
            smtp.UseDefaultCredentials = false;
            smtp.Credentials           = new System.Net.NetworkCredential(supportEmail.EmailAddres, supportEmail.Password); // Enter seders User name and password
            smtp.EnableSsl             = true;
            smtp.Send(mail);
        }
예제 #4
0
 public Email Get()
 {
     return(_manager.Get());
 }