/// <summary> /// Login user action /// </summary> /// <param name="param"></param> public void LoginUser(object param) { if (!string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(Password)) { var logic = new LoginLogic(); IsEnableLogin = false; var status = SingletonLicense.Instance.IsNetworkAvilable; if (status) { status = logic.AuthenticateUser(Email, Password); } else { MessageBox.Show("Network Not available"); return; } if (status) { SingletonLicense.Instance.IsUserLoggedIn = true; NavigateNextPage?.Invoke(null, null); IsEnableLogin = true; } else { MessageBox.Show(logic.ErrorMessage); logic.ErrorMessage = String.Empty; IsEnableLogin = true; } } }
public void LogOut(object param) { UpdateLogoutStatus(AppState.Instance.User.UserId, ServiceType.OnPremiseWebApi); if (AppState.Instance.IsSuperAdmin) { UpdateLogoutStatus(AppState.Instance.User.ServerUserId, ServiceType.CentralizeWebApi); } AppState.Instance.User = null; AppState.Instance.UserLicenseList = null; AppState.Instance.IsUserLoggedIn = false; NavigateNextPage?.Invoke("login", null); }
public void LoadTeams() { HttpClient client = AppState.CreateClient(ServiceType.OnPremiseWebApi.ToString()); client.DefaultRequestHeaders.Add("Authorization", "Bearer " + AppState.Instance.OnPremiseToken.access_token); string url = "api/Team/GetTeamsByUserId/"; if (AppState.Instance.IsSuperAdmin) { url = "api/Team/GetTeamsByAdminId/"; } var response = client.GetAsync(url + AppState.Instance.User.UserId).Result; if (response.IsSuccessStatusCode) { var jsonData = response.Content.ReadAsStringAsync().Result; var teamList = JsonConvert.DeserializeObject <List <Team> >(jsonData); if (teamList.Count > 1) { AppState.Instance.TeamList = teamList; Views.Teams teamWindow = new Views.Teams(); teamWindow.ClosePopupWindow += CloseWindow; teamWindow.ShowDialog(); } else if (teamList.Count == 1) { AppState.Instance.SelectedTeam = teamList.FirstOrDefault(); ConcurrentUserLogin userLogin = new ConcurrentUserLogin(); userLogin.TeamId = AppState.Instance.SelectedTeam.Id; userLogin.UserId = AppState.Instance.User.UserId; client = AppState.CreateClient(ServiceType.OnPremiseWebApi.ToString()); client.DefaultRequestHeaders.Add("Authorization", "Bearer " + AppState.Instance.OnPremiseToken.access_token); response = client.PostAsJsonAsync("api/User/IsConcurrentUserLoggedIn", userLogin).Result; jsonData = response.Content.ReadAsStringAsync().Result; var userLoginObj = JsonConvert.DeserializeObject <ConcurrentUserLogin>(jsonData); if (userLoginObj.IsUserLoggedIn) { NavigateNextPage?.Invoke("Dashboard", null); } else { MessageBox.Show(userLoginObj.ErrorOrNotificationMessage); } } } }
private void CloseWindow(object sender, EventArgs e1) { (sender as System.Windows.Window).Close(); if (AppState.Instance.UserLogin == null) { return; } if (AppState.Instance.UserLogin.IsUserLoggedIn) { NavigateNextPage?.Invoke("Dashboard", null); } else { AppState.Instance.User = null; AppState.Instance.UserLicenseList = null; AppState.Instance.IsUserLoggedIn = false; MessageBox.Show(AppState.Instance.UserLogin.ErrorOrNotificationMessage); } }
/// <summary> /// redirect to loginPage /// </summary> /// <param name="parameter">parameter</param> private void BackToLoginPageCommandExecuted(object parameter) { NavigateNextPage?.Invoke(null, null); }