private async void AuthUser(string username, string password, MetroWindow CurrentWindow, MetroDialogSettings mySettings) { int logInUser = DataProvider.Ins.DB.users.Where(x => x.username.Equals(username) && x.password.Equals(password)).ToArray().Count(); if (logInUser == 0) { await Application.Current.Dispatcher.Invoke(async() => { await CurrentWindow.ShowMessageAsync("Hello!", "Wrong username or password.", MessageDialogStyle.Affirmative, mySettings); }); } else if (logInUser == 1) { int idUser = DataProvider.Ins.DB.users.Where(x => x.username.Equals(username) && x.password.Equals(password)).ToArray()[0].id; await Task.Factory.StartNew(() => { Console.WriteLine("Load Username"); MainViewModel.Ins.LoadUserName(idUser); }); await Task.Factory.StartNew(() => { Console.WriteLine("Load data"); SettingViewModel.LoadData(); }); await Application.Current.Dispatcher.Invoke(async() => { Console.WriteLine("Loged in"); await CurrentWindow.ShowMessageAsync("Hello!", "Log in success.", MessageDialogStyle.Affirmative, mySettings); isLogin = true; }); } else { await Application.Current.Dispatcher.Invoke(async() => { await CurrentWindow.ShowMessageAsync("Hello!", "Wrong username or password.", MessageDialogStyle.Affirmative, mySettings); }); } }
private MainViewModel() { SettingViewModel.Init(); SettingsCommand = new RelayCommand <MetroAnimatedTabControl>((p) => { return(true); }, (p) => { p.SelectedIndex = 6; }); }