private async Task <long> CreateThreadForRecipients(Recipients recipients, int recipientCount, int distributionType) { long[] recipientIds = getRecipientIds(recipients); string recipientsList = getRecipientsAsString(recipientIds); var thread = new Thread() { Date = DateTime.Now, RecipientIds = recipientsList, //Recipients = recipients.getRecipientsList(), Count = 0 }; if (recipientCount > 1) { thread.Type = distributionType; } context.Add(thread); await context.SaveChangesAsync(); return(thread.ThreadId); }