コード例 #1
0
        private void BtnSignUp_Click(object sender, RoutedEventArgs e)
        {
            if (txtPasswordOne.IsVisible)
            {
                txtPasswordOneTxt.Text = txtPasswordOne.Password;
            }
            else
            {
                txtPasswordOne.Password = txtPasswordOneTxt.Text;
            }

            if (txtPasswordTwo.IsVisible)
            {
                txtPasswordTwoTxt.Text = txtPasswordTwo.Password;
            }
            else
            {
                txtPasswordTwo.Password = txtPasswordTwoTxt.Text;
            }

            if (!CheckIfAllCorrect())
            {
                return;
            }

            playerBasicInfo.Id       = 0;
            playerBasicInfo.Login    = txtLogin.Text;
            playerBasicInfo.Email    = txtEmail.Text;
            playerBasicInfo.Password = txtPasswordOne.Password;
            playerBasicInfo.IsAdmin  = false;

            string url = _hostUrl + "/api/jsstudygame/player";

            playerBasicInfo.Id = ServerWorker.SendPlayerToServer(playerBasicInfo, url);

            if (playerBasicInfo.Id == 0)
            {
                MessageBox.Show("Adding error! Try again!");
                return;
            }

            if (playerBasicInfo.Id == -1 || playerBasicInfo.Id == -3)
            {
                lblLoginError.Content = "Sorry! This login is already in use!";
                txtLogin.IsReadOnly   = false;
            }

            if (playerBasicInfo.Id == -2 || playerBasicInfo.Id == -3)
            {
                lblEmailError.Content = "Sorry! This email is already in use!";
                txtEmail.IsReadOnly   = false;
            }

            if (playerBasicInfo.Id < 0)
            {
                return;
            }

            MainWindow.playerLogin    = playerBasicInfo.Login;
            MainWindow.playerPassword = playerBasicInfo.Password;

            playerAddInfo.IdPlayerAdditionalInfo = playerBasicInfo.Id;
            playerAddInfo.Name    = txtName.Text;
            playerAddInfo.Surname = txtSurname.Text;

            playerAddInfo.Photo     = photoUser.ToBase64String();
            playerAddInfo.BirthDate = dateChoose.SelectedDate.Value;

            url = _hostUrl + "/api/jsstudygame/playeraddinfo";
            playerAddInfo.IdPlayerAdditionalInfo = ServerWorker.SendPlayerToServer(playerAddInfo, url);

            if (playerAddInfo.IdPlayerAdditionalInfo == 0)
            {
                MessageBox.Show("Adding Additional Information error! Try again!");
            }
            else
            {
                MessageBox.Show("Account was successfully registered!\nWe sent you mail!");
                this.Close();
            }
        }