Exemple #1
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            User user = new User()
            {
                Name     = Name.Text,
                Password = Password.Text
            };

            if (Name.Text.Count() == 0)
            {
                MessageBox.Show("user Name cannot be blank");
                return;
            }
            if (Password.Text.Count() == 0)
            {
                MessageBox.Show("password cannot be blank");
                return;
            }
            User user1 = users.Where(u => u.Name == Name.Text).SingleOrDefault();

            if (user1 != null)
            {
                MessageBox.Show("User already exists");
                return;
            }
            else
            {
                user.Level = 2;
                vm.Saveuser(user);
            }
            users.Add(user);
            UserInfo.Visibility = Visibility.Hidden;
            PassInfo.Visibility = Visibility.Hidden;
            Create.Visibility   = Visibility.Hidden;
            Name.Text           = "";
            Password.Text       = "";
            CreateUser.Focus();
        }