private void RegisterUser() { if (_CommandReg.parameter is PasswordBox) { _password = ((PasswordBox)_CommandReg.parameter).Password; if (_password.Length == 0) { MessageBox.Show("Password cannot be empty"); return; } modelLogin.UPassword = _password; if (modelLogin.isUserExist() == false) { modelLogin.SaveNewUser(); GalleryMain galleryMain = new GalleryMain(); ViewModelGallery viewmodelgalery = new ViewModelGallery(new string[] { Login, Name }); galleryMain.DataContext = viewmodelgalery; galleryMain.Show(); OnRequestClose(this, EventArgs.Empty); } else { MessageBox.Show("User '" + Login + "' is already registered", "User Exist", MessageBoxButton.OK); } } }
private void CheckPassword() { if (_CommandLogOn.parameter is PasswordBox) { _password = ((PasswordBox)_CommandLogOn.parameter).Password; modelLogin.UPassword = _password; if (modelLogin.isUserExist()) { if (modelLogin.isAccessGranted()) { GalleryMain galleryMain = new GalleryMain(); ViewModelGallery viewmodelgalery = new ViewModelGallery(new string[] { Login, modelLogin.UName }); galleryMain.DataContext = viewmodelgalery; galleryMain.Show(); OnRequestClose(this, EventArgs.Empty); } else { MessageBox.Show("User exist, but Password is incorrect", "Password Error", MessageBoxButton.OK); } } else if (MessageBox.Show("User '" + Login + "' not found in the system! Register new one?", "No such user", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { GalleryRegister register = new GalleryRegister(); ViewModelRegister modelRegister = new ViewModelRegister(modelLogin); register.DataContext = modelRegister; modelRegister.OnRequestClose += delegate(object viewsender, EventArgs args) { register.Close(); }; register.Show(); OnRequestClose(this, EventArgs.Empty); } } }