public Task<SmtpCommandReply> HandleRcptTo(string recipientAddress) { var accountRepository = _container.GetInstance<IAccountRepository>(); var account = accountRepository.GetByNameAsync(recipientAddress).Result; var recipient = new Recipient { AccountId = account != null ? account.Id : 0, Address = recipientAddress, OriginalAddress = recipientAddress }; _state.Recipients.Add(recipient); return SmtpCommandReply.CreateDefault250SuccessTask(); }
public async Task InsertAsync(Recipient messageRecipient) { using (var sqlConnection = new MySqlConnection(_connectionString)) { sqlConnection.Open(); var messageRecipientId = await sqlConnection.InsertAsync<long>(messageRecipient); messageRecipient.Id = messageRecipientId; } }
public async Task DeleteRecipientAsync(Recipient recipient) { if (recipient == null) throw new ArgumentNullException(nameof(recipient)); using (var sqlConnection = new MySqlConnection(_connectionString)) { sqlConnection.Open(); await sqlConnection.DeleteAsync(recipient); } }