async void OnLogin(object sender, EventArgs e) { Button button = (Button)sender; button.IsEnabled = false; this.IsBusy = true; try { string username = usernameData.Text; string password = passwordData.Text; //bool user = false; if (!(string.IsNullOrEmpty(username)) && !(string.IsNullOrEmpty(password))) { if (status == "Enterprise") { if (username.Equals("admin_temploy")) { var adminlogin = await adminmanager.LoginAdmin(username, password); if (adminlogin != null) { await Navigation.PushModalAsync(new NavigationPage(new HomeAdmin())); } else { await DisplayAlert("Login Failed", "Wrong Username and/or Password!", "Cancel"); } } else { var entlogin = await entmanager.LoginEnterprise(username, password); if (string.IsNullOrEmpty(entlogin.Username)) { await DisplayAlert("Enterprise Login Failed", "Wrong Username and/or Password!", "Cancel"); } else if (entlogin.Status.Equals("Pending")) { await DisplayAlert("Alert Message", "You account still waiting approval from admin.", "Cancel"); } else if (entlogin.Status.Equals("Banned")) { await DisplayAlert("Alert Message", "Your account has been banned by admin.", "Cancel"); } else { await DisplayAlert("Enterprise Login Successful", "Login Successful!", "Cancel"); await Navigation.PushModalAsync(new NavigationPage(new HomeEnterprise(entlogin))); } } } else { var jslogin = await jsmanager.LoginJobSeeker(username, password); if (string.IsNullOrEmpty(jslogin.Username)) { await DisplayAlert("JS Login Failed", "Wrong Username and/or Password!" + jslogin.Username, "Cancel"); } else if (jslogin.Status.Equals("Banned")) { await DisplayAlert("Alert Message", "Your account has been banned by admin.", "Cancel"); } else { string entusername = null, address = null; await DisplayAlert("JS Login Successful", "Login Successful!", "Cancel"); await Navigation.PushModalAsync(new NavigationPage(new HomeJobSeeker(jslogin, entusername, address))); } } } else { await DisplayAlert("Login Failed", "Please enter Username and Password.", "Re-Login"); } } finally { this.IsBusy = false; button.IsEnabled = true; } }