Ejemplo n.º 1
0
 /// <summary>
 /// On validation, new user is registered.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnRegister_Click(object sender, EventArgs e)
 {
     // Starting a connection with the CasinoDB for User and Record tables.
     playerDAO = new PlayerDAO(connString);
     recordDAO = new RecordDAO(connString);
     // Condition checks for duplicate account registrations.
     if (playerDAO.UserNameExists(txtUsername.Text))
     {
         txtUsername.Text = "Username already exists.";
         if (playerDAO.UserEmailExists(txtEmail.Text))
         {
             txtEmail.Text = "Email already exists.";
         }
     }
     else
     {
         // Creates salted hash password for new registered player.
         GeneratePasswordSaltedHash(txtPass.Text);
         // Sets the new registered players starting balance.
         int balance = Player.STARTING_BALANCE;
         // Creates new instances of Player and Record for DAO classes.
         Player player = new Player(txtUsername.Text, txtFirstName.Text, txtLastName.Text, txtEmail.Text, base64Password, base64Salt, balance);
         Record record = new Record(player.UserName, 0, 0, 0, 0);
         // Adds a new registered Player to User table and create their new record.
         playerDAO.AddPlayer(player);
         recordDAO.AddNewRecord(record);
         // Redirects to MainMenu page when registration is complete.
         Response.Redirect("/MainMenu.aspx");
     }
 }