예제 #1
0
 public AuthViewModel()
 {
     SignInCommand = new DelegateCommand <AuthDialog>(authDialog =>
     {
         if (!string.IsNullOrEmpty(Login) && !string.IsNullOrEmpty(authDialog.PasswordBox.Password))
         {
             _model.Login    = Login;
             _model.Password = authDialog.PasswordBox.Password;
             if (_model.SignIn())
             {
                 // Close current window and open MainWindow.
                 var mainWindow = new MainWindow();
                 mainWindow.Show();
                 authDialog.Close();
             }
         }
         else
         {
             MessageBox.Show("Please fill all required fields!");
         }
     });
     SignUpCommand = new DelegateCommand <AuthDialog>(authDialog =>
     {
         if (!string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Login) &&
             !string.IsNullOrEmpty(authDialog.PasswordBox.Password))
         {
             _model.Name     = Name;
             _model.Login    = Login;
             _model.Password = authDialog.PasswordBox.Password;
             if (_model.SignUp())
             {
                 // Close current window and open MainWindow.
                 var mainWindow = new MainWindow();
                 mainWindow.Show();
                 authDialog.Close();
             }
             else
             {
                 MessageBox.Show("Invalid credentials."); // Or no internet connection.
             }
         }
         else
         {
             MessageBox.Show("Please fill all required fields!");
         }
     });
 }
예제 #2
0
        private bool LoadUserData()
        {
            // TODO: Loading Screen

            UpdateMacAddress();

            ProcessData.LoadData();

            AuthenticationUser.GetInstance().UpdateToken();

            if (AuthenticationUser.GetInstance().IsDataValid())
            {
                // Creating AuthView to initialize AuthModel _goToApp action
                AuthView authView = new AuthView(GoToApp, false);
                AuthModel.SignIn();
                return(true);
            }

            return(false);
        }