Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async void btnNext_Clicked(object sender, EventArgs e)
- {
- try
- {
- HttpClient client = new HttpClient();
- var response = await client.GetStringAsync("http://ipoladroid01-001-site1.btempurl.com/Restserver/index.php/users/view");
- var user = JsonConvert.DeserializeObject<List<Users>>(response);
- for (int i = 0; i < user.Count; i++)
- {
- if (entUsername.Text == user[i].mem_acc_username)
- {
- _continue = false;
- DisplayAlert("Notice", "This username is already used please choose another.", "OK");
- entUsername.Focus();
- }
- else
- {
- _continue = true;
- }
- }
- if (_continue == true)
- {
- if (entUsername.Text == null || entUsername.Text == "")
- {
- DisplayAlert("Notice", "Please input your desire username.", "OK");
- }
- else
- {
- if (entUsername.Text.Length < 8)
- {
- DisplayAlert("Notice", "Username must include 8-32 characters", "OK");
- }
- else
- {
- if (entPassword.Text == null || entPassword.Text == "")
- {
- DisplayAlert("Notice", "Please input your desire password.", "OK");
- }
- else
- {
- if (entPassword.Text.Length < 8)
- {
- DisplayAlert("Notice", "Password must include 8-45 characters", "OK");
- }
- else
- {
- if (entFname.Text == null || entFname.Text == "")
- {
- DisplayAlert("Notice", "Please input your Firstname.", "OK");
- }
- else
- {
- if (entLname.Text == null || entLname.Text == "")
- {
- DisplayAlert("Notice", "Please input your Password", "OK");
- }
- else
- {
- tempusername = entUsername.Text;
- temppassword = entPassword.Text;
- tempfname = entFname.Text;
- templname = entLname.Text;
- var u = new Users();
- u.mem_acc_username = tempusername;
- u.mem_acc_password = temppassword;
- u.mem_fname = tempfname;
- u.mem_lname = templname;
- var page1 = new Registration2(u);
- Navigation.PushAsync(page1);
- _continue = false;
- }
- }
- }
- }
- }
- }
- }
- else
- {
- DisplayAlert("Notice", "Something went wrong please try again.", "OK");
- }
- }
- catch(Exception ex)
- {
- DisplayAlert("Network error", "Please check your internet connection and try again.", "OK");
- }
- }
- ///// Reg 2
- private async void btnRegister_Clicked(object sender, EventArgs e)
- {
- if (entAddress.Text == null | entAddress.Text == "")
- {
- DisplayAlert("Notice", "Please fill-up your current address.", "OK");
- entAddress.Focus();
- }
- else
- {
- if (entContact.Text == null || entContact.Text == "")
- {
- DisplayAlert("Notice", "Please input your phone number", "OK");
- }
- else
- {
- if (entContact.Text.Length < 11 )
- {
- DisplayAlert("Notice", "Enter a valid phone number", "OK");
- }
- else
- {
- Users users = new Users()
- {
- mem_acc_username = tempusername,
- mem_acc_password = temppassword,
- mem_fname = tempfname,
- mem_lname = templname,
- mem_address = entAddress.Text,
- mem_mobile_no = entContact.Text,
- mem_bday = dateselected
- };
- var page2 = new Registration3(users);
- Navigation.PushAsync(page2);
- }
- }
- }
- }
- //// Reg 3
- private async Task btnRegister_Clicked(object sender, EventArgs e)
- {
- try
- {
- if (entBirth.SelectedIndex < 0)
- {
- DisplayAlert("Notice", "Please select a Security Question", "OK");
- }
- else
- {
- if(entAnswer.Text == null || entAnswer.Text == "")
- {
- DisplayAlert("Notice", "Please input your answer", "OK");
- entAnswer.Focus();
- }
- else
- {
- if(ent5digit.Text == null || ent5digit.Text == "")
- {
- DisplayAlert("Notice", "Please input your membership code, if you don't have membership code feel free to contact us.", "OK");
- }
- else
- {
- btnRegister.IsEnabled = false;
- Send5Digit sendthis = new Send5Digit()
- {
- membership_code = ent5digit.Text
- };
- var json1 = JsonConvert.SerializeObject(sendthis);
- var content1 = new StringContent(json1, Encoding.UTF8, "application/json");
- HttpClient client1 = new HttpClient();
- var result1 = await client1.PostAsync("http://ipoladroid01-001-site1.btempurl.com/Restserver/index.php/customer/search_codes", content1);
- // var result1 = await client1.PostAsync("http://192.168.43.178/Restserver/index.php/customer/search_codes", content1);
- response = await result1.Content.ReadAsStringAsync();
- // await DisplayAlert("Debug", response, "OK");
- if (response == "[]")
- {
- await DisplayAlert("Notice", "Invalid Code", "OK");
- btnRegister.IsEnabled = true;
- }
- else
- {
- var validator = JsonConvert.DeserializeObject<List<Send5Digit>>(response);
- var memcode = validator[0].membership_code;
- var code = validator[0].code_number;
- var stat = validator[0].code_status;
- await DisplayAlert("Debug", memcode + code + stat, "OK");
- Send5Digit codez = new Send5Digit()
- {
- code_number = code
- };
- var json2 = JsonConvert.SerializeObject(codez);
- var content2 = new StringContent(json2, Encoding.UTF8, "application/json");
- HttpClient client2 = new HttpClient();
- var result2 = await client1.PostAsync("http://ipoladroid01-001-site1.btempurl.com/Restserver/index.php/customer/update_registered_codes", content2);
- // var result2 = await client1.PostAsync("http://192.168.43.178/Restserver/index.php/customer/update_registered_codes", content2);
- if (result2.StatusCode == System.Net.HttpStatusCode.Created)
- {
- Users users = new Users()
- {
- mem_acc_username = tempmem_acc_username,
- mem_acc_password = tempmem_acc_password,
- mem_question = temp,
- mem_answer = entAnswer.Text,
- mem_fname = tempmem_fname,
- mem_lname = tempmem_lname,
- mem_address = tempmem_address,
- mem_mobile_no = tempmem_mobile,
- mem_bday = tempmem_bday,
- };
- var json = JsonConvert.SerializeObject(users);
- var content = new StringContent(json, Encoding.UTF8, "application/json");
- HttpClient client = new HttpClient();
- var result = await client.PostAsync("http://ipoladroid01-001-site1.btempurl.com/Restserver/index.php/users/insert", content);
- // var result = await client.PostAsync("http://192.168.43.178/Restserver/index.php/users/insert", content);
- if (result.StatusCode == System.Net.HttpStatusCode.Created)
- {
- await DisplayAlert("Success :", "Account Registered", "OK");
- btnRegister.IsEnabled = true;
- Navigation.PushAsync(new MainPage());
- }
- else
- {
- await DisplayAlert("Failed", result.ToString(), "OK");
- btnRegister.IsEnabled = true;
- }
- }
- else
- {
- await DisplayAlert("Failed", result2.ToString(), "OK");
- }
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- DisplayAlert("Hmmmm", "Something went wrong please try again later.", "OK");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement