public static ClientPartnerRelationEntity CreateNew(string email, string clientId, string partnerId) { string partnerPublicId = partnerId ?? ""; string clientEmail = email.ToLower(); var result = new ClientPartnerRelationEntity { PartitionKey = GeneratePartitionKey(clientEmail), RowKey = GenerateRowKey(partnerPublicId), Email = clientEmail, PartnerId = partnerPublicId, ClientId = clientId, Registered = DateTime.UtcNow }; return(result); }
public async Task <IEnumerable <IClientAccount> > GetByEmailAsync(string email) { if (string.IsNullOrEmpty(email)) { return(null); } IEnumerable <ClientPartnerRelationEntity> relations = await _clientPartnerTablestorage.GetDataAsync(ClientPartnerRelationEntity.GeneratePartitionKey(email)); IEnumerable <string> rowKeys = relations.Select(x => x.ClientId); return((await _clientsTablestorage.GetDataAsync(ClientAccountEntity.GeneratePartitionKey(), rowKeys)) .Append(await _clientsTablestorage.GetDataAsync(_emailIndices, IndexEmail, GetEmailPartnerIndexRowKey(email, null))) .Except(new ClientAccountEntity[] { null }, ClientAccountEntity.ComparerById) .Distinct(ClientAccountEntity.ComparerById).ToArray()); }
public async Task <IClientAccount> RegisterAsync(IClientAccount clientAccount, string password) { var newEntity = ClientAccountEntity.CreateNew(clientAccount, password); string partnerId = clientAccount.PartnerId; string indexRowKey = GetEmailPartnerIndexRowKey(newEntity); var indexEntity = AzureIndex.Create(IndexEmail, indexRowKey, newEntity); ClientPartnerRelationEntity clientPartner = ClientPartnerRelationEntity.CreateNew(clientAccount.Email, newEntity.Id, newEntity.PartnerId); await _emailIndices.InsertAsync(indexEntity); await _clientsTablestorage.InsertAsync(newEntity); await _clientPartnerTablestorage.InsertAsync(clientPartner); return(newEntity); }