public ActionResult DeletePlaylist(int id)
        {
            var service = new PlaylistService();

            service.DeletePlaylist(id);
            TempData["SaveResult"] = "Playlist was deleted";
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public async Task ModifierAsync([Remainder] string parameters)
        {
            await Context.Channel.TriggerTypingAsync();

            string[] args   = parameters.Split(" ");
            ulong    userId = Context.Message.Author.Id;

            var textChannel = Context.Channel as ITextChannel;
            await textChannel.TriggerTypingAsync();

            var embed = new EmbedBuilder();

            switch (args[0])
            {
            case "create":
                if (args.Length == 2)
                {
                    embed.WithDescription($"Created playlist: {args[1]}");
                    embed.AddField("Begin adding songs with command:", ".list add <playlist name> <song name>", false);
                    await ReplyAsync(null, false, PlaylistService.CreatePlaylist(userId, args[1]));

                    return;
                }
                embed.WithDescription(".list create <playlist name>");
                await ReplyAsync(null, false, embed.Build());

                return;

            case "del":
                await ReplyAsync(null, false, PlaylistService.DeletePlaylist(userId, args[1]));

                return;

            case "add":
                if (args.Length > 2)
                {
                    var array = args.Where((item, index) => index >= 2).ToArray();
                    var name  = string.Join(" ", array);
                    await ReplyAsync(null, false, await PlaylistService.AddSongAsync(userId, args[1], name));

                    return;
                }
                embed.WithDescription(".list add <playlist name> <song name>");
                await ReplyAsync(null, false, embed.Build());

                return;

            case "rem":
                return;

            default:
                await ReplyAsync("unknown sub-command");

                return;
            }
        }
Пример #3
0
 private void DeletePlaylist(PlaylistToDisplay obj)
 {
     try
     {
         PlaylistService.DeletePlaylist(obj.id);
         RefreshPlaylists();
     }
     catch (Exception ex)
     {
         Logger.LogError(this, ex.Message);
         ShowErrorMessage("There was an error during deleting playlist.");
     }
 }
        public async Task <IActionResult> DeletePlaylist([FromRoute] int playlistId)
        {
            int userId = ClaimHelper.FindNameIdentifier(HttpContext.User.Claims);

            var response = await _playlistService.DeletePlaylist(userId, playlistId);

            if (!response.Success)
            {
                return(BadRequest(response.Message));
            }

            var playlistDto = _mapper.Map <Playlist, PlaylistDto>(response.Resource);

            return(Ok(playlistDto));
        }