public async Task SetMoneyAsync(long discordUserId, long guildId, int money)
        {
            AsyncDataReader dr = new AsyncDataReader("MONEY_SetMoney", _credentials.DbConnectionString);

            dr.AddParameter("@DiscordUserId", discordUserId);
            dr.AddParameter("@DiscordGuildId", guildId);
            dr.AddParameter("@Money", money);

            await dr.ExecuteNonQueryAsync();
        }
Пример #2
0
        public async Task AddPokemonAsync(long discordUserId, long guildId, PokemonSummary pokemon)
        {
            AsyncDataReader dr = new AsyncDataReader("POKEMON_AddPokemonToInventory", _connectionString);

            dr.AddParameter("@DiscordGuildId", guildId);
            dr.AddParameter("@DiscordUserId", discordUserId);
            dr.AddParameter("@PokemonNumber", pokemon.Id);
            dr.AddParameter("@PokemonName", pokemon.Name);

            await dr.ExecuteNonQueryAsync();
        }
Пример #3
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);
        }
Пример #4
0
        public async Task <RemoveSongResult> RemoveSongFromPlaylistByIndexAsync(long discordUserId, string playlistName, int index)
        {
            AsyncDataReader dr = new AsyncDataReader("PLAYLIST_RemoveSongByIndex", _credentials.DbConnectionString);

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

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

            return(result);
        }
Пример #5
0
        public async Task <AddSongResult> AddSongToPlaylistAsync(long discordUserId, string playlistName, PlaylistSong song)
        {
            AsyncDataReader dr = new AsyncDataReader("PLAYLIST_AddSong", _credentials.DbConnectionString);

            dr.AddParameter("@DiscordUserId", discordUserId);
            dr.AddParameter("@PlaylistName", playlistName);
            dr.AddParameter("@SongName", song.Name);
            dr.AddParameter("@SongUrl", song.Url);

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

            return(result);
        }
        public async Task <DonateMoneyResult> DonateMoneyAsync(long donorDiscordUserId, long doneeDiscordUserId, long guildId, int amount)
        {
            AsyncDataReader dr = new AsyncDataReader("MONEY_DonateMoney", _credentials.DbConnectionString);

            dr.AddParameter("@DonorDiscordUserId", donorDiscordUserId);
            dr.AddParameter("@DoneeDiscordUserId", doneeDiscordUserId);
            dr.AddParameter("@DiscordGuildId", guildId);
            dr.AddParameter("@Amount", amount);

            try
            {
                return((DonateMoneyResult)await dr.ExecuteScalarAsync());
            } catch
            {
                return(DonateMoneyResult.TransactionFailed);
            }
        }
        public async Task <int> GetMoneyAsync(long discordUserId, long guildId)
        {
            AsyncDataReader dr = new AsyncDataReader("MONEY_GetMoney", _credentials.DbConnectionString);

            dr.AddParameter("@DiscordUserId", discordUserId);
            dr.AddParameter("@DiscordGuildId", guildId);

            int money = 0;
            await dr.ExecuteReaderAsync(reader =>
            {
                money = reader.GetInt32(reader.GetOrdinal("MONEY"));

                return(Task.CompletedTask);
            });

            return(money);
        }
Пример #8
0
        public async Task <Models.Playlist> GetPlaylistAsync(long discordUserId, string playlistName)
        {
            AsyncDataReader dr = new AsyncDataReader("PLAYLIST_GetPlaylist", _credentials.DbConnectionString);

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

            Models.Playlist playlist = null;
            await dr.ExecuteReaderAsync(reader =>
            {
                GetPlaylistWithSongsFromReader(reader, ref playlist);

                return(Task.CompletedTask);
            });

            return(playlist);
        }
Пример #9
0
        public async Task <Dictionary <PokemonSummary, int> > GetPokemonAsync(long discordUserId, long guildId)
        {
            AsyncDataReader dr = new AsyncDataReader("POKEMON_GetPokemonInventory", _connectionString);

            dr.AddParameter("@DiscordGuildId", guildId);
            dr.AddParameter("@DiscordUserId", discordUserId);

            Dictionary <PokemonSummary, int> pokemon = new Dictionary <PokemonSummary, int>();
            await dr.ExecuteReaderAsync(reader =>
            {
                int amount = reader.GetInt32(reader.GetOrdinal("AMOUNT"));
                pokemon.TryAdd(GetPokemonSummaryFromReader(reader), amount);

                return(Task.CompletedTask);
            });

            return(pokemon);
        }
Пример #10
0
        public async Task <List <Models.Playlist> > GetPlaylistsAsync(long discordUserId)
        {
            AsyncDataReader dr = new AsyncDataReader("PLAYLIST_GetPlaylists", _credentials.DbConnectionString);

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

            List <Models.Playlist> playlists = new List <Models.Playlist>();
            await dr.ExecuteReaderAsync(reader =>
            {
                playlists.Add(GetPlaylistFromReader(reader));

                return(Task.CompletedTask);
            });

            return(playlists);
        }