/// <summary> /// Handles all validation of Credentials for sign up /// </summary> /// <returns>The credentials.</returns> public CredentialInformation ValidateCredentials() { CredentialInformation CredInfo = new CredentialInformation(); if (!IsProperUsername()) { CredInfo.Errors.Add("Invalid Username"); } if (!PasswordsMatch()) { CredInfo.Errors.Add("Passwords do not match"); } if (!IsProperPassword()) { CredInfo.Errors.Add("Password is not proper"); } if (UserExists()) { CredInfo.Errors.Add("Username already exists"); } if (CredInfo.IsValid()) { PostRequest post = new PostRequest(); string hi = post.PostInfo(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("username", TryUsername.Text), new KeyValuePair <string, string>("user_password", TryPassword.Text) }, "http://haydenszymanski.me/softeng05/register_participant.php").ResponseInfo; } return(CredInfo); }
/// <summary> /// Check to see if the username already exists in the database /// </summary> Boolean UserExists() { PostRequest post = new PostRequest(); Debug.WriteLine("UserExist"); //return post.UserExists(TryUsername.Text, TryPassword.Text); return(!(post.PostInfo(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("username", TryUsername.Text) }, "http://haydenszymanski.me/softeng05/get_user_type.php").ResponseInfo.Equals("none"))); }
/// <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(); }); }); } }
public void WhiteBoxTest_PostRequest_PostInfo_Success() { List <KeyValuePair <string, string> > userList = new List <KeyValuePair <string, string> >(); KeyValuePair <string, string> testUsers = new KeyValuePair <string, string>("TestUser", "TestUser1!"); userList.Add(testUsers); PostRequest post = new PostRequest(); var result = post.PostInfo(userList, "http://haydenszymanski.me/softeng05/get_events.php"); Assert.IsTrue(result.ResponseSuccess); }
/// <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(); }); }); }