C# Class BlottoBeats.Server.Database

Handles all communication with the MySQL database
Show file Open project: Zwolf11/BlottoBeats Class Usage Examples

Private Methods

Method Description
Authenticate ( Credentials credentials, bool register ) : UserToken

Attemts to register a new user or authenticate an existing user with the given credentials

Database ( string connString ) : System

Loads a database from the given connection string

Database ( string hostID, int port, string databaseName, string userID, string password ) : System

Loads a database from the given connection string

GetID ( SongParameters song ) : int

Searches the database for a song that matches the given song. If there is a match, returns the ID. If not, returns -1

GetID ( string username ) : int

Returns id of an item from the users table

GetNextAvailableID ( string table ) : int

Gets the next available ID for the server

GetSong ( int id ) : SongParameters

Returns the song with the given ID

GetSongList ( int numSongs, string genre, string username ) : List

Gets a list of songs that match the given SongParameters object

GetUsername ( int id ) : string

Returns the username of a user with the given ID

RefreshSong ( SongParameters song ) : SongParameters

Returns the given song with updated ID, score and user data. Does not add the song to the database if it isn't already there.

RefreshToken ( string username ) : bool

Refreshes the user token of a user, effectively forcing them to login again.

SQLNonQuery ( MySqlConnection conn, string comString ) : void

Performs an SQL NonQuery to the database

SongExists ( int id ) : bool

Checks to see if a song with the given ID exists in the database.

TestConnection ( ) : int

Tests the connection to the database

VerifyToken ( UserToken tokenToVerify ) : int

Verifies a user token

VoteOnSong ( SongParameters song, bool vote, int userID ) : SongParameters

Checks to see if a song is in the database already. If it isn't, the song is added to the database with a single vote. If it is, add the vote to that song.

addVoteToUserTable ( int userID, int songID, bool vote ) : void
changePassword ( int userID, string hash ) : void
changeVoteScore ( int songID, int newScore ) : void
checkAndChangeVote ( int userID, int songID, bool vote ) : int
createUser ( string username, string hash ) : bool
createUserTable ( int userID ) : void
deleteSong ( int songID ) : void
deleteUser ( int userID ) : void
getUserHash ( int userID ) : string
getUserToken ( int userID ) : UserToken
insertData ( SongParameters song ) : void
returnItem ( int id, string col, string table ) : object
storeUserToken ( int userID, System.DateTime expires, string token ) : void
updateScore ( int id, int voteAmount ) : void