public static async Task <bool> DeleteTrackFollow(string userId, string trackId, bool ownerOverride = false) { try { TrackAuth track = await TrackRepository.GetTrack(trackId); if (track.PartitionKey == userId && ownerOverride == false) { return(false); } UserFollowTableEntity userFollow = await TableStorageRepository.GetUserFollow(userId, trackId); TrackFollowTableEntity trackFollow = await TableStorageRepository.GetTrackFollow(trackId, userId); if (userFollow != null) { await TableStorageRepository.DeleteUserFollow(userFollow); } if (trackFollow != null) { await TableStorageRepository.DeleteTrackFollow(trackFollow); } return(true); } catch { return(false); } }
internal static async void InsertOrReplaceUserFollow(UserFollowTableEntity userFollowTableEntity) { // reference users table CloudTable table = tableClient.GetTableReference(UserFollowsTable); await table.CreateIfNotExistsAsync(); // insert the user TableOperation op = TableOperation.InsertOrReplace(userFollowTableEntity); await(dynamic) table.ExecuteAsync(op); }
internal static async Task <bool> DeleteUserFollow(UserFollowTableEntity userFollow) { try { // reference track table CloudTable table = tableClient.GetTableReference(UserFollowsTable); await table.CreateIfNotExistsAsync(); TableOperation op = TableOperation.Delete(userFollow); var result = await table.ExecuteAsync(op); return(result == null ? false : true); } catch { return(false); } }