예제 #1
0
 private void BtnAddFriend_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (db.Users.Any(x => x.Account == txtFriendAccount.Text))
     {
         User friend = db.Users.Where(x => x.Account == txtFriendAccount.Text).First();
         db.Friends.Add(new Friend()
         {
             UserId   = user.Id,
             FriendId = friend.Id
         });
         db.SaveChanges();
         ShowFriends(user);
     }
 }
예제 #2
0
        private void Button_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ChattingRoomEntities db = new ChattingRoomEntities();

            if (db.Users.Any(x => x.Account == txtAccount.Text))
            {
                MessageBox.Show("This account is existed.");
            }
            else
            {
                db.Users.Add(new User()
                {
                    Name     = txtName.Text,
                    Account  = txtAccount.Text,
                    Password = Auth.Hash(txtPassword.Password)
                });
                db.SaveChanges();
                MessageBox.Show("Regist success! Please try to login your account.");
                ((Frame)Application.Current.MainWindow.FindName("pnlFrame")).Navigate(new PageSignin());
            }
        }