public Chat(UserR user) { InitializeComponent(); name = user.UserName; Action <string> targetFunc = ReceiveMessage; chatHubProxy.On("ReceiveMessage", targetFunc); hubConnection.Start().Wait(); }
private void btn_signup_Click(object sender, RoutedEventArgs e) { UserR user = new UserR(); if (tb_name.Text.Length >= 3 && tb_name.Text.Length <= 10) { user.UserName = tb_name.Text; } else { console.Text = "Username has to be between 3 and 10 chars long"; return; } if (pb_passwd.Password.Length >= 6) { if (pb_passwd.Password == pb_passwd2.Password) { user.Password = pb_passwd.Password; } else { console.Text = "Passwords are not identical"; } } else { console.Text = "Password has to be at least 6 chars long"; return; } user.PreName = tb_preName.Text; user.LastName = tb_surName.Text; try { entities.UserR.Add(user); entities.SaveChanges(); } catch (System.Data.Entity.Infrastructure.DbUpdateException) { console.Text = "There is already an User with this Name"; return; } MainWindow window = new MainWindow(); window.Show(); this.Close(); }