示例#1
0
        public async Task GivenEmail_WhenCreate_ThenCreateSuccessful()
        {
            //?Given
            var id           = "1234";
            var userName     = "******";
            var creationTime = new DateTime();

            var email = new Email
            {
                Id           = id,
                UserName     = userName,
                CreationTime = creationTime
            };

            var emailEntity = new EmailEntity
            {
                Id           = id,
                UserName     = userName,
                CreationTime = creationTime
            };

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

            //?When
            await _emailRepository.Create(email);

            //?Then
            _mockMapper.Verify();
            _mockService.Verify();
            _mockService.Verify(t => t.Create(It.IsAny <string>(), It.Is <EmailEntity>(e => EmailIsWellCreated(e, email))), Times.Once);
        }
        public bool SendEmail(EmailModel email)
        {
            //try
            //{
            //    MailMessage mail = new MailMessage(_myEmail, _myEmail);
            //    SmtpClient client = new SmtpClient();
            //    client.EnableSsl = true;
            //    client.Port = 587;
            //    client.UseDefaultCredentials = false;

            //    NetworkCredential nc = new NetworkCredential(_myEmail, _myEmailPass);
            //    client.Credentials = nc;
            //    client.DeliveryMethod = SmtpDeliveryMethod.Network;
            //    client.UseDefaultCredentials = false;
            //    client.Host = "smtp.gmail.com";
            //    mail.Subject = "New Inquiry - PhoneNumber: " + email.PhoneNumber + "EmailAddress: "+ email.EmailAddress;
            //    mail.Body = email.Message;
            //    client.Send(mail);
            //}
            //catch (Exception e)
            //{
            //    Console.WriteLine(e);
            //    return false;
            //}
            var newEmail = new Email
            {
                EmailAddress = email.EmailAddress,
                Message      = email.Message,
                PhoneNumber  = email.PhoneNumber,
                Name         = email.Name
            };

            _emailRepository.Create(newEmail);
            return(true);
        }
示例#3
0
        public async Task CreateEmailAsync(Email item)
        {
            item.id = await Repository.GetNextIdAsync();

            Repository.Create(item);
            await Repository.SaveAsync();
        }
示例#4
0
        public async Task Create(Email email)
        {
            email.Id = email.GenerateGuid();
            email.GenerateCreationTime();

            await _repository.Create(email);
        }
示例#5
0
        public async Task Create(Person personToSave, Address addressToSave, Email emailToSave, Phone phoneNumberToSave,
                                 Personal personalToSave)
        {
            await _context.Persons.AddAsync(personToSave);

            await _context.SaveChangesAsync();

            addressToSave.PersonId = personToSave.Id;
            await _addressRepository.Create(addressToSave);

            emailToSave.PersonId = personToSave.Id;
            await _emailRepository.Create(emailToSave);

            personalToSave.PersonId = personToSave.Id;
            await _personalRepository.Create(personalToSave);

            phoneNumberToSave.PersonId = personToSave.Id;
            await _phoneRepository.Create(phoneNumberToSave);
        }
示例#6
0
        public IHttpActionResult Create(string value)
        {
            try
            {
                var xml  = StringToXml.ToXml(value);
                var root = GetResult(xml);

                _emailRepository.Create(new EmailRecord {
                    Data = xml
                });
                return(new CustomResponse(HttpStatusCode.OK, root.root));
            }
            catch (Exception ex)
            {
                return(new CustomResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
示例#7
0
        public void Post([FromBody] JObject value)
        {
            // example of handling an event

            var orderEvent = value.ToObject <OrderEvent>();

            var orderInfo = JsonConvert.DeserializeObject <OrderEventData>(orderEvent.Body);

            if (string.Equals(orderEvent.EventType, "OrderCreated", StringComparison.OrdinalIgnoreCase))
            {
                var email = new Email
                {
                    Body = $"New order created with OrderID {orderInfo.OrderId}!",
                };
                _emailRepository.Create(email);
            }

            _orderRepository.AcknowledgeEvent(orderEvent.EventId);
        }
示例#8
0
        public int CreateEmailTemplate(EmailTemplateCreateModel model, UserIdentity <int> issuer = null)
        {
            var emailTemplate = _mapper.Map <EmailTemplate>(model);

            if (issuer != null)
            {
                emailTemplate.CreateBy(issuer).UpdateBy(issuer);
            }
            _emailRepository.Create(emailTemplate);
            _uow.SaveChanges();
            return(emailTemplate.Id);
        }
示例#9
0
 public async Task CreateForRecipient(AddEmailToRecipientViewModel model)
 {
     await _emailRepo.Create(new Email(model.RecipientId, model.TemplateId));
 }
 public void Create(Email item)
 {
     repository.Create(item);
 }