public void Execute(object parameter) { if (mLoginViewModel.CanLogin()) { if (mLoginViewModel.Login()) { if (mLoginViewModel.CurrentUser.Accounts.Count == 0) { MessageBox.Show("Jelenleg nincs számlája, kérem hozzon létre egyet!", "Hiányzó számla"); var newAccount = new AccountViewModel(mLoginViewModel.CurrentUser); if (newAccount.CreateInteractive() == false) { return; } } mainWindowView = new MainWindowView(mLoginViewModel.CurrentUser.UserID); mainWindowView.Show(); } else { MessageBox.Show("Rossz felhasználónév vagy jelszó!"); mLoginViewModel.loginPage.clearPassword(); } } }
public async Task CanLoginIfDataIsCorrect() { var options = new DbContextOptionsBuilder <SPDbContext>().UseInMemoryDatabase("inMemoryDb.db").Options; var ctx = new SPDbContext(options); var repo = new GenericRepository <Person>(ctx); var encryptedPassword = Helper.PasswordHelper.GetHash("password1"); repo.AddOrUpdate(new Model.Person { FirstName = "Test", Credentials = new Model.AccessData() { UserName = "******", EncryptedPassword = encryptedPassword } }); repo.AddOrUpdate(new Model.Person { FirstName = "Test", Credentials = new Model.AccessData() { UserName = "******", EncryptedPassword = encryptedPassword } }); repo.AddOrUpdate(new Model.Person { FirstName = "Test", Credentials = new Model.AccessData() { UserName = "******", EncryptedPassword = encryptedPassword } }); LoginViewModel sut = new LoginViewModel("unitTest", new PeopleLogic(repo)); //Assert.IsFalse(sut.CanLogin()); sut.UserName = "******"; sut.Password = "******"; Assert.IsFalse(await sut.CanLogin()); sut.UserName = "******"; sut.Password = "******"; Assert.IsTrue(await sut.CanLogin()); IWindowService _fakeWin = ServiceContainer.GetService <IWindowService>(); Assert.IsTrue(sut.LogInCommand.CanExecute(null)); //sut.LogInCommand.Execute(null); }
void OnLoginClicked(object sender, EventArgs e) { if (viewModel.CanLogin()) { viewModel .LoginAsync(System.Threading.CancellationToken.None) .ContinueWith(_ => { App.LastUseTime = System.DateTime.UtcNow; parent.Title = "Employee Directory"; // remove " Login" Navigation.PopModalAsync(); }); parent.Title = "Employee Directory"; // remove " Login" Navigation.PopModalAsync(); } else { DisplayAlert("Error", viewModel.ValidationErrors, "OK"); } }
void OnLoginClicked(object sender, EventArgs e) { if (viewModel.CanLogin()) { viewModel .LoginAsync(System.Threading.CancellationToken.None) .ContinueWith(_ => { App.LastUseTime = System.DateTime.UtcNow; Navigation.PopModalAsync(); }); Navigation.PopModalAsync(); } else { DisplayAlert("Error", viewModel.ValidationErrors, "OK", null); } }
public bool CanExecute(object parameter) { return(receiver.CanLogin()); }