Exemple #1
0
 private void btnSubmit_OnClick(object sender, RoutedEventArgs e)
 {
     if (txbLogin.Text == "" || txbPass.Password == "")
     {
         ErrorDialog errorDialog = new ErrorDialog("Error!!! Fill all the fields!!!");
         errorDialog.Show();
     }
     else
     {
         DbConnectionFactory connectionFactory = new DbConnectionFactory("FoodDiaryConnectionString");
         DbContext           context           = new DbContext(connectionFactory);
         UserRepository      userRepository    = new UserRepository(context);
         string hasedPassword = HashedPassword.GetMd5Hash(txbPass.Password);
         int    userId        = userRepository.GetUserByLogin(txbLogin.Text, hasedPassword);
         if (userId > 0)
         {
             MainWindow userMainWindow = new MainWindow(context, userId);
             userMainWindow.Closed += delegate { Show(); };
             userMainWindow.Show();
             Hide();
         }
         else
         {
             ErrorDialog errorDialog = new ErrorDialog("Error!!! Incorrect data inputed!!!");
             errorDialog.Show();
         }
     }
 }