Пример #1
0
        public async Task <ActionResult> Delete(string pk, string rk, IFormCollection collection)
        {
            try
            {
                var timer = await TableStorageService.RetrieveEntity <BotTimers>(pk, rk, Constants.BotTimersTableName);

                await TableStorageService.DeleteEntity(timer, Constants.BotTimersTableName);

                return(RedirectToAction("Index", "BotTimers", new { ac = "The timer was successfully removed!", type = "success" }));
            }
            catch
            {
                return(View());
            }
        }
Пример #2
0
        public async Task <ActionResult> Delete(string pk, string rk, IFormCollection collection)
        {
            try
            {
                var command = await TableStorageService.RetrieveEntity <CustomCommands>(pk, rk, Constants.CustomCommandsTableName);

                await TableStorageService.DeleteEntity(command, Constants.CustomCommandsTableName);

                return(RedirectToAction("Index", "Commands", new { ac = "The command was successfully removed!", type = "success" }));
            }
            catch
            {
                return(View());
            }
        }
        public async Task <ActionResult> Delete(string pk, string rk, IFormCollection collection)
        {
            try
            {
                var song = await TableStorageService.RetrieveEntity <AllSongs>(pk, rk, Constants.AllSongsTableName);

                await TableStorageService.DeleteEntity(song, Constants.AllSongsTableName);

                return(RedirectToAction("Index", "Playlist", new { ac = "The song was successfully removed!", type = "success" }));
            }
            catch
            {
                return(View());
            }
        }
Пример #4
0
        public async Task <ActionResult> RemoveRequest(string pk, string rk)
        {
            var song = await TableStorageService.RetrieveEntity <AzureTableSong>(pk, rk, Constants.QueueTableName);

            if (song != null)
            {
                await TableStorageService.DeleteEntity(song, Constants.QueueTableName);

                var updateSong = await TableStorageService.RetrieveEntity <AllSongs>(pk, rk, Constants.AllSongsTableName);

                updateSong.PartitionKey      = song.PartitionKey;
                updateSong.RowKey            = song.RowKey;
                updateSong.Counter           = song.Counter - 1;
                updateSong.LastTimeRequested = DateTime.UtcNow.AddHours(-2);

                await TableStorageService.MergeEntity(updateSong, Constants.AllSongsTableName);

                var queueSongs = await TableStorageService.RetrieveAllEntities <AzureTableSong>(Constants.QueueTableName);

                var table = TableStorageService.ConnectToTable(Constants.QueueTableName);

                if (queueSongs.Count > 0)
                {
                    queueSongs = queueSongs.OrderBy(x => x.Position).ToList();
                    var position = 1;

                    foreach (var queueSong in queueSongs)
                    {
                        queueSong.Position = position;
                        queueSong.Counter  = queueSong.Counter - 1;

                        var replace = TableOperation.Merge(queueSong);
                        await table.ExecuteAsync(replace);

                        position++;
                    }
                }

                return(RedirectToAction("Index", "SongsQueue", new { ac = "The song was removed from the queue.", type = "success" }));
            }
            else
            {
                return(RedirectToAction("Index", "SongsQueue", new { ac = "Error. The song does not exist.", type = "danger" }));
            }
        }