Exemple #1
0
        private void btnEnter_Click(object sender, RoutedEventArgs e)
        {
            Person newPerson = new Person {
                Name = UserNameTextBox.Text, Password = Sha256Tools.GetHash(PasswordTextBox.Password)
            };

            if (Authentification.Authentify(newPerson) && UserNameTextBox.Text != "" && PasswordTextBox.Password != "")
            {
                System.Windows.Forms.MessageBox.Show("You are already register, please use the sign in button", "User issue!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else if (!Authentification.Authentify(newPerson) && UserNameTextBox.Text != "" && PasswordTextBox.Password != "")
            {
                using (var context = new ShowContext())
                {
                    context.Add(newPerson);
                    UserSingleton.GetInstance.user = newPerson;
                    context.SaveChanges();
                    System.Windows.Forms.MessageBox.Show("You are registered now");
                    this.Close();
                }
            }
            else if (UserNameTextBox.Text == "" || PasswordTextBox.Password == "")
            {
                System.Windows.Forms.MessageBox.Show("You have to fill both boxes", "User issue!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        private void btnEnter_Click(object sender, RoutedEventArgs e)
        {
            Person newPerson = new Person {
                Name = UserNameTextBox.Text, Password = Sha256Tools.GetHash(PasswordTextBox.Password)
            };

            if (Authentification.Authentify(newPerson))
            {
                using (var context = new ShowContext())
                {
                    UserSingleton.GetInstance.user = context.Persons.Where(x => x.Name == newPerson.Name).FirstOrDefault();
                }
                System.Windows.MessageBox.Show("You have log yourself!");
                this.Close();
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Username or password invalid", "User issue!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }