/// <summary> /// When the next button is clicked, we run all the credentials through to see if the meet our ideal criteria for a properly /// formed set of credentials. /// Upon success we update the database with the new user and the local current user static fields /// </summary> void OnNextClick(object sender, EventArgs e) { CredentialInformation CredInfo = ValidateCredentials(); if (!CredInfo.IsValid()) { DisplayAlert("Error", CredInfo.ErrorsAsString(), "Continue"); } else { Task.Run(async() => { ActiveUser = await JsonRequest.GetUserData <User>( new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("username", TryUsername.Text), new KeyValuePair <string, string>("user_password", TryPassword.Text) }, "http://haydenszymanski.me/softeng05/get_user.php"); Device.BeginInvokeOnMainThread(() => { Navigation.InsertPageBefore(new ProfileUpdatePage(ActiveUser), Navigation.NavigationStack.First()); Navigation.PopToRootAsync(); }); }); } }
/// <summary> /// /// </summary> void OnProfileEditClick(object sender, EventArgs args) { Debug.WriteLine(ActiveUser.Id); PostRequest post = new PostRequest(); Debug.WriteLine(post.PostInfo(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("user_id", ActiveUser.Id), new KeyValuePair <string, string>("user_zip", Zip.Text), new KeyValuePair <string, string>("user_phone", Phone.Text), new KeyValuePair <string, string>("user_first", First.Text), new KeyValuePair <string, string>("user_last", Last.Text), new KeyValuePair <string, string>("user_address", Address.Text), new KeyValuePair <string, string>("user_profile_picture", ProfileImage.Text), new KeyValuePair <string, string>("user_about_me", AboutMe.Text), new KeyValuePair <string, string>("user_email", Email.Text), new KeyValuePair <string, string>("user_state", "") }, "http://haydenszymanski.me/softeng05/update_user.php").ResponseSuccess); /// <summary> /// after we update the database, we then immediately query that database to update our local static current user fields /// currently there is a bug that likely has to due with the timing of this task. In the future, all we need to do is /// change the local static fields according to the text we inputted /// NOTE: Bug Fixed /// </summary> Task.Run(async() => { ActiveUser = await JsonRequest.GetUserData <User>(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("username", ActiveUser.UserName), new KeyValuePair <string, string>("user_password", ActiveUser.Password) }, "http://haydenszymanski.me/softeng05/get_user.php"); Device.BeginInvokeOnMainThread(() => { ActiveUser.Zip = Zip.Text; ActiveUser.PhoneNumber = Phone.Text; ActiveUser.FirstName = First.Text; ActiveUser.LastName = Last.Text; ActiveUser.Address = Address.Text; ActiveUser.ProfilePicture = ProfileImage.Text; ActiveUser.AboutMe = AboutMe.Text; ActiveUser.PhoneNumber = Phone.Text; ActiveUser.Email = Email.Text; Navigation.InsertPageBefore(new ProfilePage(ActiveUser), Navigation.NavigationStack.First()); Navigation.PopToRootAsync(); }); }); }
/// <summary> /// On sign in click popular current user static fields with remote user info /// /// </summary> void SignInClick(object sender, EventArgs args) { PostRequest post = new PostRequest(); String userType = post.PostInfo(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("username", Username.Text) }, "http://haydenszymanski.me/softeng05/get_user_type.php").ResponseInfo; /* * switch (userType) * { * case "organizer" : * Debug.WriteLine("organizer"); * break; * case "participant" : * Debug.WriteLine("participant"); * break; * case "none" : * Debug.WriteLine("none"); * break; * } */ if (post.PostInfo(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("username", Username.Text), new KeyValuePair <string, string>("user_password", Password.Text) }, "http://haydenszymanski.me/softeng05/login_user.php").ResponseInfo.Equals("Success")) { Task.Run(async() => { User UserSigningIn = await JsonRequest.GetUserData(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("username", Username.Text), new KeyValuePair <string, string>("user_password", Password.Text) }, "http://haydenszymanski.me/softeng05/get_user.php"); Device.BeginInvokeOnMainThread(() => { Navigation.InsertPageBefore(new ProfilePage(UserSigningIn), Navigation.NavigationStack.First()); Navigation.PopToRootAsync(); }); }); } }