Example #1
0
        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);
            }
        }
Example #2
0
 private static TrackFollow TableEntityToTrackFollow(TrackFollowTableEntity tableEntity)
 {
     return(new TrackFollow()
     {
         track_id = tableEntity.PartitionKey,
         user_id = tableEntity.RowKey,
         feed_follow_type = tableEntity.feed_follow_type,
         notifications_follow_type = tableEntity.notifications_follow_type,
         criteria = JsonConvert.DeserializeObject <List <TagCriteria> >(tableEntity.criteria)
     });
 }
        internal static async void InsertOrReplaceTrackFollow(TrackFollowTableEntity trackFollow)
        {
            // reference users table
            CloudTable table = tableClient.GetTableReference(TrackFollowsTable);
            await table.CreateIfNotExistsAsync();

            // insert the user
            TableOperation op = TableOperation.InsertOrReplace(trackFollow);

            await(dynamic) table.ExecuteAsync(op);
        }
        internal static async Task <bool> DeleteTrackFollow(TrackFollowTableEntity trackFollow)
        {
            try
            {
                // reference track table
                CloudTable table = tableClient.GetTableReference(TrackFollowsTable);
                await table.CreateIfNotExistsAsync();

                TableOperation op     = TableOperation.Delete(trackFollow);
                var            result = await table.ExecuteAsync(op);

                return(result == null ? false : true);
            }
            catch
            {
                return(false);
            }
        }
Example #5
0
        public static async Task <TrackFollow> GetTrackFollow(string trackId, string userId)
        {
            TrackFollowTableEntity result = await TableStorageRepository.GetTrackFollow(trackId, userId);

            return(TableEntityToTrackFollow(result));
        }