///<inheritdoc cref="IMessageSendService.SendEmail(SmtpClient, Message)"/> public async Task SendEmailNow(string smtpServer, IEnumerable <MailMessage> mailMessages, bool isSheduled = false) { if (isSheduled == false) { try { DataValidate(smtpServer, mailMessages); } catch (EmailSendServiceException ex) { throw ex; } } var sender = _senderRepository.GetAll().Where(x => x.Email == mailMessages.FirstOrDefault().From.Address).FirstOrDefault().ToDomain(); var allRecipients = _recipientRepository.GetAll(); var messageRecipients = new List <Recipient>(); using (var client = GetSmtpClient(sender, smtpServer)) { foreach (var mail in mailMessages) { var recipient = allRecipients.Where(x => x.Email == mail.To.FirstOrDefault().Address).FirstOrDefault(); messageRecipients.Add(recipient.ToDomain()); await client.SendMailAsync(mail); } } if (isSheduled == false) { var sendedMessage = new Message() { SenderId = sender.Id, Body = mailMessages.FirstOrDefault().Body, Title = mailMessages.FirstOrDefault().Subject, SendDateTime = DateTime.Now }; _messageRepository.Add(sendedMessage.ToEntity()); } ; foreach (var rec in messageRecipients) { _recipient2MessageRepository.Add(new Recipient2MessageEntity() { MessageId = _messageRepository.GetAll().Select(x => x.Id).LastOrDefault(), RecipientId = rec.Id }); } }
private void simpleButtonSave_Click(object sender, EventArgs e) { ProcessTabKey(true); if (Validation() == false) { return; } if (_item.Id == 0) { _item = _repo.Add(_item); } else { _repo.Update(_item); } DialogResult = DialogResult.OK; }
public virtual MessageObject <T> Add(T entity) { MessageObject <T> validationResult = ValidateAdd(entity); try { BasePreProcessing(ref entity, OperationType.Add); if (validationResult.ProcessingStatus) { validationResult.Data = repo.Add(entity); repo.Commit(); BasePostProcessing(ref entity, OperationType.Add); } } catch (Exception ex) { Utils.Logger.Log(ex, logSource); validationResult.AddException(ex); } return(validationResult); }
public void Add(Host host) { _repository.Add(host.ToEntity()); }
public void Add(Sender sender) { _repository.Add(sender.ToEntity()); }
/// <summary> /// 写入实体数据 /// </summary> /// <param name="entity">实体类</param> /// <returns></returns> public async Task <int> Add(T entity) { return(await BaseDal.Add(entity)); }
public void Add(Recipient recipient) { _repository.Add(recipient.ToEntity()); }