async void RootCreate(object sender, EventArgs e) //CREATE account button { /* Method: RootCreate * Programmer: Harry Martin * Description: This method accepts the user input * Creates a new user object and writes it to the online database * This will overwrite any existing user on the server with the same name * The password will be hashed (SHA254) */ //Clear current loaded user (if any) ActiveProfile.UnloadProfile(); //Get the values from the user prompts String w_username = UserN.Text; String w_password = PassW.Text; //Write these to a local user profile object UserProfile local_UP = ActiveProfile.Instance; local_UP.username = w_username; local_UP.password = CryptoHandler.Hash(w_password); //Serialize and encode the object String enc_json = WebMethod.Serialize(local_UP); //DEBUG: await DisplayAlert("Alert", "About to attempt following POST: \n" + enc_json, "OK"); //Do the HTTP request and get the result String createResult = WebMethod.GetResult("save", "users/" + w_username, enc_json, "POST"); if (createResult == "ok") { await DisplayAlert("Alert", "User succesfully created.", "OK"); } else { await DisplayAlert("Alert", createResult, "OK"); } }
async void Exit(object sender, EventArgs e) //Back to Root Navigation { ActiveProfile.UnloadProfile(); await Navigation.PopToRootAsync(); }