async void SignUpNewUser(System.Object sender, System.EventArgs e) { if (isAddessValidated) { var directSignUpSerializedObject = JsonConvert.SerializeObject(directSignUp); var content = new StringContent(directSignUpSerializedObject, Encoding.UTF8, "application/json"); System.Diagnostics.Debug.WriteLine(directSignUpSerializedObject); var signUpclient = new HttpClient(); var RDSResponse = await signUpclient.PostAsync(Constant.SignUpUrl, content); Debug.WriteLine("RDSResponse: " + RDSResponse.ToString()); var RDSMessage = await RDSResponse.Content.ReadAsStringAsync(); Debug.WriteLine("RDSMessage: " + RDSMessage.ToString()); // if Sign up is has successfully ie 200 response code if (RDSResponse.IsSuccessStatusCode) { var RDSData = JsonConvert.DeserializeObject<SignUpResponse>(RDSMessage); Debug.WriteLine("RDSData: " + RDSData.ToString()); DateTime today = DateTime.Now; DateTime expDate = today.AddDays(Constant.days); if (RDSData.message.Contains("taken")) { DisplayAlert("Error", "email address is already in use", "OK"); } else { // Local Variables in Xamarin that can be used throughout the App Application.Current.Properties["user_id"] = RDSData.result.customer_uid; Application.Current.Properties["time_stamp"] = expDate; Application.Current.Properties["platform"] = "DIRECT"; System.Diagnostics.Debug.WriteLine("UserID is:" + (string)Application.Current.Properties["user_id"]); System.Diagnostics.Debug.WriteLine("Time Stamp is:" + Application.Current.Properties["time_stamp"].ToString()); System.Diagnostics.Debug.WriteLine("platform is:" + (string)Application.Current.Properties["platform"]); string url = "https://ht56vci4v9.execute-api.us-west-1.amazonaws.com/dev/api/v2/Profile/" + (string)Application.Current.Properties["user_id"]; var request3 = new HttpRequestMessage(); request3.RequestUri = new Uri(url); request3.Method = HttpMethod.Get; var client2 = new HttpClient(); HttpResponseMessage response = await client2.SendAsync(request3); HttpContent content2 = response.Content; Console.WriteLine("content: " + content2); var userString = await content2.ReadAsStringAsync(); JObject info_obj2 = JObject.Parse(userString); this.NewMainPage.Clear(); Preferences.Set("profilePicLink", null); // Go to Subscripton page // Application.Current.MainPage = new SubscriptionPage(); //send email to verify email emailVerifyPost emailVer = new emailVerifyPost(); emailVer.email = emailEntry.Text.Trim(); var emailVerSerializedObj = JsonConvert.SerializeObject(emailVer); var content4 = new StringContent(emailVerSerializedObj, Encoding.UTF8, "application/json"); var client3 = new HttpClient(); var response3 = client3.PostAsync("https://ht56vci4v9.execute-api.us-west-1.amazonaws.com/dev/api/v2/email_verification", content4); Console.WriteLine("RESPONSE TO CHECKOUT " + response3.Result); Console.WriteLine("CHECKOUT JSON OBJECT BEING SENT: " + emailVerSerializedObj); Application.Current.MainPage = new NavigationPage(new SubscriptionPage((info_obj2["result"])[0]["customer_first_name"].ToString(), (info_obj2["result"])[0]["customer_last_name"].ToString(), (info_obj2["result"])[0]["customer_email"].ToString())); } } } else { await DisplayAlert("Message", "We weren't able to sign you up", "OK"); } }
async void SignUpNewUser(System.Object sender, System.EventArgs e) { var directSignUpSerializedObject = JsonConvert.SerializeObject(directSignUp); var content = new StringContent(directSignUpSerializedObject, Encoding.UTF8, "application/json"); System.Diagnostics.Debug.WriteLine(directSignUpSerializedObject); var signUpclient = new HttpClient(); var RDSResponse = await signUpclient.PostAsync(Constant.SignUpUrl, content); Debug.WriteLine("RDSResponse: " + RDSResponse.ToString()); var RDSMessage = await RDSResponse.Content.ReadAsStringAsync(); Debug.WriteLine("RDSMessage: " + RDSMessage.ToString()); // if Sign up is has successfully ie 200 response code if (RDSResponse.IsSuccessStatusCode) { var RDSData = JsonConvert.DeserializeObject <SignUpResponse>(RDSMessage); Debug.WriteLine("RDSData: " + RDSData.ToString()); DateTime today = DateTime.Now; DateTime expDate = today.AddDays(Constant.days); if (RDSData.message.Contains("taken")) { DisplayAlert("Error", "email address is already in use, please log in", "OK"); } else { // Local Variables in Xamarin that can be used throughout the App Application.Current.Properties["user_id"] = RDSData.result.customer_uid; Application.Current.Properties["time_stamp"] = expDate; Application.Current.Properties["platform"] = "DIRECT"; System.Diagnostics.Debug.WriteLine("UserID is:" + (string)Application.Current.Properties["user_id"]); System.Diagnostics.Debug.WriteLine("Time Stamp is:" + Application.Current.Properties["time_stamp"].ToString()); System.Diagnostics.Debug.WriteLine("platform is:" + (string)Application.Current.Properties["platform"]); string url = "https://ht56vci4v9.execute-api.us-west-1.amazonaws.com/dev/api/v2/Profile/" + (string)Application.Current.Properties["user_id"]; var request3 = new HttpRequestMessage(); request3.RequestUri = new Uri(url); request3.Method = HttpMethod.Get; var client2 = new HttpClient(); HttpResponseMessage response = await client2.SendAsync(request3); HttpContent content2 = response.Content; Console.WriteLine("content: " + content2); var userString = await content2.ReadAsStringAsync(); JObject info_obj2 = JObject.Parse(userString); this.NewMainPage.Clear(); Preferences.Set("profilePicLink", null); // Go to Subscripton page // Application.Current.MainPage = new SubscriptionPage(); //send email to verify email emailVerifyPost emailVer = new emailVerifyPost(); emailVer.email = Preferences.Get(savedEmail, ""); var emailVerSerializedObj = JsonConvert.SerializeObject(emailVer); var content4 = new StringContent(emailVerSerializedObj, Encoding.UTF8, "application/json"); var client3 = new HttpClient(); var response3 = client3.PostAsync("https://ht56vci4v9.execute-api.us-west-1.amazonaws.com/dev/api/v2/email_verification", content4); Console.WriteLine("RESPONSE TO CHECKOUT " + response3.Result); Console.WriteLine("CHECKOUT JSON OBJECT BEING SENT: " + emailVerSerializedObj); Console.WriteLine("\nUser Signed Up:" + "\n email: " + directSignUp.email + "\n first name: " + directSignUp.first_name + "\n last name: " + directSignUp.last_name + "\n phone number: " + directSignUp.phone_number + "\n address: " + directSignUp.address + "\n unit: " + directSignUp.unit + "\n city: " + directSignUp.city + "\n state: " + directSignUp.state + "\n zip: " + directSignUp.zip_code + "\n latitude: " + directSignUp.latitude + "\n longitude: " + directSignUp.longitude + "\n referral source: " + directSignUp.referral_source + "\n role: " + directSignUp.role + "\n mobile access token: " + directSignUp.mobile_access_token + "\n mobile refresh token: " + directSignUp.mobile_refresh_token + "\n user access token: " + directSignUp.user_access_token + "\n user refresh token: " + directSignUp.user_refresh_token + "\n social: " + directSignUp.social + "\n password: "******"\n social id: " + directSignUp.social_id ); Application.Current.MainPage = new NavigationPage(new Select(passingZones, cust_firstName, cust_lastName, cust_email)); } } }