/// <summary> /// Insert user /// </summary> /// <param name="storageConsistencyMode">Storage consistency mode</param> /// <param name="userHandle">User handle</param> /// <param name="identityProviderType">Identity provider type</param> /// <param name="accountId">Account id</param> /// <param name="appHandle">App handle</param> /// <param name="firstName">First name</param> /// <param name="lastName">Last name</param> /// <param name="bio">User bio</param> /// <param name="photoHandle">Photo handle</param> /// <param name="visibility">User visibility</param> /// <param name="createdTime">Created time</param> /// <param name="requestId">Request Id</param> /// <returns>Insert user task</returns> public async Task InsertUser( StorageConsistencyMode storageConsistencyMode, string userHandle, IdentityProviderType identityProviderType, string accountId, string appHandle, string firstName, string lastName, string bio, string photoHandle, UserVisibilityStatus visibility, DateTime createdTime, string requestId) { UserProfileEntity userProfileEntity = new UserProfileEntity() { FirstName = firstName, LastName = lastName, Bio = bio, CreatedTime = createdTime, LastUpdatedTime = createdTime, Visibility = visibility, PhotoHandle = photoHandle, ReviewStatus = ReviewStatus.Active, RequestId = requestId }; AppFeedEntity appFeedEntity = new AppFeedEntity() { AppHandle = appHandle }; LinkedAccountFeedEntity linkedAccountFeedEntity = new LinkedAccountFeedEntity() { IdentityProviderType = identityProviderType, AccountId = accountId }; CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Users); ObjectTable profilesTable = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserProfilesObject) as ObjectTable; FeedTable appsTable = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserAppsFeed) as FeedTable; FeedTable accountsTable = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserLinkedAccountsFeed) as FeedTable; Transaction transaction = new Transaction(); transaction.Add(Operation.Insert(profilesTable, userHandle, appHandle, userProfileEntity)); transaction.Add(Operation.Insert(appsTable, userHandle, this.tableStoreManager.DefaultFeedKey, appHandle, appFeedEntity)); transaction.Add(Operation.Insert(accountsTable, userHandle, this.tableStoreManager.DefaultFeedKey, identityProviderType.ToString(), linkedAccountFeedEntity)); await store.ExecuteTransactionAsync(transaction, storageConsistencyMode.ToConsistencyMode()); }
/// <summary> /// Insert linked account /// </summary> /// <param name="storageConsistencyMode">Storage consistency mode</param> /// <param name="userHandle">User handle</param> /// <param name="identityProviderType">Identity provider type</param> /// <param name="accountId">Account id from identity provider</param> /// <returns>Insert linked account task</returns> public async Task InsertLinkedAccount( StorageConsistencyMode storageConsistencyMode, string userHandle, IdentityProviderType identityProviderType, string accountId) { LinkedAccountFeedEntity linkedAccountFeedEntity = new LinkedAccountFeedEntity() { IdentityProviderType = identityProviderType, AccountId = accountId }; CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Users); FeedTable accountsTable = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserLinkedAccountsFeed) as FeedTable; Operation operation = Operation.Insert(accountsTable, userHandle, this.tableStoreManager.DefaultFeedKey, identityProviderType.ToString(), linkedAccountFeedEntity); await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode()); }