/// <summary> /// create a new playlist in the database and get its id. /// </summary> private void createPlaylist() { try { StringBuilder query = new StringBuilder(); query.Append("Insert into playlist(playlist_name, Users_idUsers) values('" + playlist.User.Name + "'," + playlist.User.ID + ")"); int n = executer.ExecuteCommandWithoutResult(query.ToString()); query.Clear(); query.Append("select idSongsPlaylist from playlist where playlist_name = '" + playlist.User.Name + "' and Users_idUsers = " + playlist.User.ID.ToString()); DataTable dt = executer.ExecuteCommandWithResults(query.ToString()); playlist.ID = dt.Rows[0].Field <int>(0); } catch (Exception ex) { Console.WriteLine(ex.Data); } }
/// <summary> /// SignUp method. /// after getting the username and password from user, check first if it /// alreay exist - if yes return false. then register him in table. /// </summary> /// <returns></returns> public Boolean SignUp() { try { String checkIfUserExist = "Select * FROM Users WHERE user_name = '" + Username + "'"; if (executer.ExecuteCommandWithResults(checkIfUserExist).Rows.Count != 0) { return(false); } String query = "INSERT INTO Users (user_name, password) VALUES ('" + Username + "','" + Password + "')"; if (executer.ExecuteCommandWithoutResult(query) != -1) { getIDFromTable(); return(true); } } catch (Exception ex) { Console.WriteLine(ex.Data); } return(false); }