Пример #1
0
        public UserSignUpViewModel(U_Sign_MainViewModel window_main_sign)
        {
            Go_to_sign_in = new RelayCommand(o =>
            {
                window_main_sign.CurrentView = new UserSignInViewModel(window_main_sign);
            }
                                             );

            Go_sign_up_again = new RelayCommand(o =>
            {
                window_main_sign.CurrentView = new UserSignUpViewModel(window_main_sign);
            }
                                                );

            User_sign_upCommand = new RelayCommand(o =>
            {
                if (IsValid)
                {
                    //Добавление в Users
                    users_db.Create(new Users(Password, Name, Surname, Otchestvo, City, Street, Convert.ToInt32(House), Convert.ToInt32(Apartament), Login, Email));
                    users_db.Save();
                    MessageBox.Show("Регистрация завершена успешно!", "Регистрация");

                    //Открытие окна для входа
                    window_main_sign.CurrentView = new UserSignInViewModel(window_main_sign);
                }
                else
                {
                    System.Windows.MessageBox.Show("Неккоректные данные!", "Регистрация");
                }
            });
        }
Пример #2
0
        public UserSignInViewModel(U_Sign_MainViewModel window_main_sign)
        {
            Go_to_sign_up = new RelayCommand(o =>
            {
                window_main_sign.CurrentView = new UserSignUpViewModel(window_main_sign);
            }
                                             );

            Go_sign_in_again = new RelayCommand(o =>
            {
                window_main_sign.CurrentView = new UserSignInViewModel(window_main_sign);
            }
                                                );

            UserSignInSuccess = new RelayCommand(o =>
            {
                int userID = 0;
                if ((userID = FindUser(new Users(Password, Login), users_db.GetDataList().ToList())) != 0)
                {
                    MainWindow mainWindow = new MainWindow(userID);

                    mainWindow.Show();

                    window_main_sign.CloseAction();
                }
                else
                {
                    System.Windows.MessageBox.Show("Неверные данные", "Авторизация");
                }
            });
        }