//Inserts the given details into the database if both email and username are not already registered //Returns a string with message indicated whether insert was succesful or reason why it wasn't public static string insert(string username, int isArtist, string email, string password) { string sql, salt; int count; int userID; string dbMessage; //Get salt and hash password salt = SqlComm.CreateSalt(); password = SqlComm.Enc(password + salt); //Check if email already registered count = (int)SqlComm.SqlReturn("emailCount @email='" + email + "'"); if (count < 1) { //Check if username already registered count = (int)SqlComm.SqlReturn("usernameCount @username='******'"); if (count < 1) { //If not already registered insert into database sql = "insertNewUser @userName='******' , @email='" + email + "', @isArtist ='" + isArtist + "',@userPassword = '******',@salt='" + salt + "'"; SqlComm.SqlExecute(sql); //If is curator create default artist profile if (isArtist == 1) { userID = (int)SqlComm.SqlReturn("getUserID @username='******'"); Artist.insert(userID, username, "", ""); } dbMessage = ""; } else { dbMessage = "Username already registered"; } } else { dbMessage = "Email already registered"; } return(dbMessage); }