/// <summary> /// Insert user topic /// </summary> /// <param name="storageConsistencyMode">Storage consistency mode</param> /// <param name="userHandle">User handle</param> /// <param name="appHandle">App handle</param> /// <param name="topicHandle">Topic handle</param> /// <returns>Insert user topic task</returns> public async Task InsertUserTopic( StorageConsistencyMode storageConsistencyMode, string userHandle, string appHandle, string topicHandle) { TopicFeedEntity topicFeedEntity = new TopicFeedEntity() { AppHandle = appHandle, TopicHandle = topicHandle, UserHandle = userHandle }; CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.UserTopics); FeedTable feedTable = this.tableStoreManager.GetTable(ContainerIdentifier.UserTopics, TableIdentifier.UserTopicsFeed) as FeedTable; CountTable countTable = this.tableStoreManager.GetTable(ContainerIdentifier.UserTopics, TableIdentifier.UserTopicsCount) as CountTable; Transaction transaction = new Transaction(); transaction.Add(Operation.Insert(feedTable, userHandle, appHandle, topicHandle, topicFeedEntity)); transaction.Add(Operation.Insert(feedTable, userHandle, MasterApp.AppHandle, topicHandle, topicFeedEntity)); transaction.Add(Operation.InsertOrIncrement(countTable, userHandle, appHandle)); transaction.Add(Operation.InsertOrIncrement(countTable, userHandle, MasterApp.AppHandle)); await store.ExecuteTransactionAsync(transaction, storageConsistencyMode.ToConsistencyMode()); }
/// <summary> /// Insert featured topic /// </summary> /// <param name="storageConsistencyMode">Storage consistency mode</param> /// <param name="appHandle">App handle</param> /// <param name="topicHandle">Topic handle</param> /// <param name="topicUserHandle">User handle</param> /// <returns>Insert featured topic task</returns> public async Task InsertFeaturedTopic( StorageConsistencyMode storageConsistencyMode, string appHandle, string topicHandle, string topicUserHandle) { TopicFeedEntity topicFeedEntity = new TopicFeedEntity() { AppHandle = appHandle, TopicHandle = topicHandle, UserHandle = topicUserHandle }; CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.FeaturedTopics); FeedTable table = this.tableStoreManager.GetTable(ContainerIdentifier.FeaturedTopics, TableIdentifier.FeaturedTopicsFeed) as FeedTable; Transaction transaction = new Transaction(); transaction.Add(Operation.Insert(table, ContainerIdentifier.FeaturedTopics.ToString(), appHandle, topicHandle, topicFeedEntity)); transaction.Add(Operation.Insert(table, ContainerIdentifier.FeaturedTopics.ToString(), MasterApp.AppHandle, topicHandle, topicFeedEntity)); await store.ExecuteTransactionAsync(transaction, storageConsistencyMode.ToConsistencyMode()); }