Esempio n. 1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            try{
                UserGender = GenderCombo.SelectedItem.ToString();

                if (!string.IsNullOrEmpty(NameBox.Text) || !string.IsNullOrEmpty(LastNameBox.Text) ||
                    !string.IsNullOrEmpty(PassBox.Text) || !string.IsNullOrEmpty(PassVBox.Text) ||
                    !string.IsNullOrEmpty(UserBox.Text) || !string.IsNullOrEmpty(UserGender))
                {
                    if (PassBox.Text == PassVBox.Text)
                    {
                        var checker = await userManager.CheckUserExistenceAsync(UserBox.Text);

                        if (!checker)
                        {
                            if (!string.IsNullOrWhiteSpace(FileLocation.Text))
                            {
                                UserProfilePic = pictureManager.UploadPicture(FileLocation.Text);
                            }
                            else
                            {
                                UserProfilePic = pictureBox1.ImageLocation;
                            }

                            await userManager.RegisterNewUserAsync(NameBox.Text, LastNameBox.Text, UserBox.Text, PassVBox.Text, UserProfilePic, UserGender);

                            MetroSetMessageBox.Show(this, "Registration was successful!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Hide();
                            loginPanel = new LoginPanel();
                            loginPanel.Show();
                            this.Close();
                        }
                        else
                        {
                            MetroSetMessageBox.Show(this, "Username is already in use!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MetroSetMessageBox.Show(this, "Passwords didn't match.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MetroSetMessageBox.Show(this, "Fill all the gaps!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (NullReferenceException ex)
            {
                MetroSetMessageBox.Show(this, "Enter your gender!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }