private async Task AddMessage(string fromNumber, string toNumber, string text, string messageSid, string direction, Address address = null) { var contact = await _contactsService.GetByPhoneNumber(toNumber); if (contact == null) { contact = new Contact { Info = new ContactInfo { Number = toNumber } }; await _contactsService.Add(contact); } if (address != null) { await _contactsService.UpdateAddress(contact.Id, address); } await _contactsService.AddMessage(contact.Id, new Message { From = fromNumber, To = toNumber, Text = text, CreatedOn = DateTime.UtcNow, Direction = direction, Sid = messageSid }); }