/// <summary> /// This method is used to change the current page to Home page and send a json file to verify the user credentials /// @author Mauricio C. /// </summary> private async void Button_Clicked(object sender, EventArgs e) { var userValidate = userEntry.Text; if (!string.IsNullOrEmpty(userValidate)) { string email = userEntry.Text; string password = "******" + CreateMD5(pasEntry.Text); HttpClient cliente = new HttpClient(); string url = "http://" + ip + ":6969/login/" + email + password; var result = await cliente.GetAsync(url); var json = result.Content.ReadAsStringAsync().Result; CookTime.REST_API_UserModel.User InputUser = new REST_API_UserModel.User(); InputUser = CookTime.REST_API_UserModel.User.FromJson(json); if (InputUser.Name == null) { await DisplayAlert("Cook Time", "The data you filled with does not match with any CookTime user. Please verify your info and try again!", "OK"); } else { CURRENTUSER = CookTime.REST_API_UserModel.User.FromJson(json); await DisplayAlert("Cook Time", "Welcome back " + CURRENTUSER.Name, "OK"); await Navigation.PushAsync(new HomePage()); } } }
/// <summary> /// This method simply updates the user information, everytime a change has been made to itself. /// @author Jose A. /// </summary> public static async void updateUser() { HttpClient cliente = new HttpClient(); string url = "http://" + ip + ":6969/login/" + CURRENTUSER.Email + "/" + CURRENTUSER.Password; var result = await cliente.GetAsync(url); var json = result.Content.ReadAsStringAsync().Result; CookTime.REST_API_UserModel.User InputUser = new REST_API_UserModel.User(); InputUser = CookTime.REST_API_UserModel.User.FromJson(json); if (InputUser.Name == null) { return; } else { CURRENTUSER = CookTime.REST_API_UserModel.User.FromJson(json); } }