Пример #1
0
        public async Task <CreatePlaylistResult> CreatePlaylistAsync(long discordUserId, string playlistName)
        {
            AsyncDataReader dr = new AsyncDataReader("PLAYLIST_CreatePlaylist", _credentials.DbConnectionString);

            dr.AddParameter("@DiscordUserId", discordUserId);
            dr.AddParameter("@PlaylistName", playlistName);

            CreatePlaylistResult result = (CreatePlaylistResult)await dr.ExecuteScalarAsync();

            return(result);
        }
Пример #2
0
        public async Task CreatePlaylistAsync(EduardoContext context, string playlistName)
        {
            if (string.IsNullOrWhiteSpace(playlistName))
            {
                return;
            }

            CreatePlaylistResult result = await _playlistRepository.CreatePlaylistAsync((long)context.User.Id, playlistName);

            await context.Channel.SendMessageAsync(result switch
            {
                CreatePlaylistResult.PlaylistExists => "You have already created a playlist with this name",
                CreatePlaylistResult.MaxPlaylistsReached => "You have reached the maximum number of playlists (5)",
                _ => $"Playlist \"{playlistName}\" created successfully!"
            });