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); }
public async Task CreateEmailAsync(Email item) { item.id = await Repository.GetNextIdAsync(); Repository.Create(item); await Repository.SaveAsync(); }
public async Task Create(Email email) { email.Id = email.GenerateGuid(); email.GenerateCreationTime(); await _repository.Create(email); }
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); }
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)); } }
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); }
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); }
public async Task CreateForRecipient(AddEmailToRecipientViewModel model) { await _emailRepo.Create(new Email(model.RecipientId, model.TemplateId)); }
public void Create(Email item) { repository.Create(item); }