public static bool Logins() { TEJUSResultModel LstTask = new TEJUSResultModel(); using (var client = new HttpClient()) { var response = client.GetAsync("http://tejus.vaspublications.com/api/Login/LogIn?username=sonith&password=sonith").Result; if (response.IsSuccessStatusCode) { // by calling .Result you are performing a synchronous call // var responseContent = response.Content; // by calling .Result you are synchronously reading the result // string responseString = responseContent.ReadAsStringAsync().Result; var content = response.Content.ReadAsStringAsync(); // LstTask = JsonConvert.DeserializeObject<TEJUSResultModel>(content); //var outObject = JsonConvert.DeserializeObject<TEJUSResultModel>(response.ToString()); ////return true; //var user = JsonConvert.DeserializeObject<TEJUSResultModel>(content); //// LstTask = (TEJUSResultModel)JsonConvert.DeserializeObject(content.ToString()); //// MyAccount.EmployeeID = (string)o["employeeid"][0]; return(true); } else { return(false); } } }
public static async Task <TEJUSResultModel> Login(string Username, string Password) { TEJUSResultModel LstTask = new TEJUSResultModel(); try { HttpClient client = new HttpClient(); client.MaxResponseContentBufferSize = 256000; string urltejus = @"http://tejus.vaspublications.com//api/Login/LogIn?username="******"&password=sonith"; var uri = new Uri(urltejus); var response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); LstTask = JsonConvert.DeserializeObject <TEJUSResultModel>(content); if (LstTask.SuccessStatus) { //DisplayAlert("Login", "Login Success", "Ok"); //NavigationPage.SetHasNavigationBar(this, false); //Navigation.PushAsync(new MasterDetailPage1()); // await SaveAsync(); saveset(Username, Password); App.Current.MainPage = new NavigationPage(new MasterDetailPage1()); } else { App.Current.MainPage = new NavigationPage(new LoginPage()); // DisplayAlert("Login", "Login Not Correct, empty username or password", "Ok"); } // ActivitySpinner.IsVisible = false; } } catch (Exception ex) { } return(LstTask); }