private void signUpTapped(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(nome.Text) || String.IsNullOrWhiteSpace(password.Text) || String.IsNullOrWhiteSpace(cognome.Text) || String.IsNullOrWhiteSpace(RipPassword.Text)) { displayError.Margin = new Thickness((width - 300) / 2, 10, (width - 300) / 2, 0); displayError.Text = "Compilare i campi"; displayError.IsVisible = true; } else { string app; displayError.IsVisible = false; if (password.Text == RipPassword.Text) { app = "{\"name\":\"" + nome.Text + "\",\"surname\":\"" + cognome.Text + "\",\"password\":\"" + Misc.MD5Hash(password.Text) + "\"}"; Task <string> task = RestService.post("/signup?type=cliente", app); Console.WriteLine("\n\nbased " + task.Result); if (task.Result == "err 204") { displayError.Margin = new Thickness((width - 300) / 2, 10, (width - 300) / 2, 0); displayError.Text = "Utente già esistente"; displayError.IsVisible = true; } else { task = RestService.get("/login?type=cliente&name=" + nome.Text + "&surname=" + cognome.Text + "&password="******"id = " + Misc.id); Navigation.PushAsync(new mainCliente()); } } else { displayError.Margin = new Thickness((width - 300) / 2, 10, (width - 300) / 2, 0); displayError.Text = "Campi password diversi"; displayError.IsVisible = true; } } }
private void logInTapped(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(nome.Text) || String.IsNullOrWhiteSpace(password.Text)) { displayError.Margin = new Thickness((width - 200) / 2, 20, (width - 200) / 2, 0); displayError.Text = "Compilare i campi"; displayError.IsVisible = true; } else { string app; displayError.IsVisible = false; Task <string> task = RestService.get("/login?type=fornitore&name=" + nome.Text + "&password="******"\n\nbased " + task.Result); if (task.Result == "err 204") { displayError.Margin = new Thickness((width - 200) / 2, 20, (width - 200) / 2, 0); displayError.Text = "Credenziali sbagliate"; displayError.IsVisible = true; } else { Misc.id = Convert.ToInt32(task.Result); Console.WriteLine("id = " + Misc.id); Navigation.PushAsync(new mainFornitore()); } } }
private void newAccountTapped(object sender, EventArgs e) { string app; if (user.SelectedIndex == 0) { if (String.IsNullOrWhiteSpace(nome.Text) || String.IsNullOrWhiteSpace(password.Text)) { displayError.Margin = new Thickness((width - 300) / 2, 70, (width - 300) / 2, 0); displayError.Text = "Compilare i campi"; displayError.IsVisible = true; } else { app = "{\"name\":\"" + nome.Text + "\",\"password\":\"" + Misc.MD5Hash(password.Text) + "\"}"; Task <string> task = RestService.post("/signup?type=fornitore", app); displayError.Margin = new Thickness((width - 300) / 2, 70, (width - 300) / 2, 0); displayError.TextColor = Color.DodgerBlue; displayError.Text = "Fornitore aggiunto"; displayError.IsVisible = true; nome.Text = ""; } } if (user.SelectedIndex == 1) { if (String.IsNullOrWhiteSpace(nome.Text) || String.IsNullOrWhiteSpace(password.Text) || state.SelectedIndex < 0 || city.SelectedIndex < 0) { displayError.Margin = new Thickness((width - 300) / 2, 70, (width - 300) / 2, 0); displayError.Text = "Compilare i campi"; displayError.IsVisible = true; } else { app = "{\"name\":\"" + nome.Text + "\",\"surname\":\"" + cognome.Text + "\",\"password\":\"" + Misc.MD5Hash(password.Text) + "\",\"idP\":" + ports[city.SelectedIndex].idP + "}"; Task <string> task = RestService.post("/signup?type=operatore", app); displayError.Margin = new Thickness((width - 300) / 2, 70, (width - 300) / 2, 0); displayError.TextColor = Color.DodgerBlue; displayError.Text = "Operatore aggiunto"; displayError.IsVisible = true; nome.Text = ""; } } else { if (String.IsNullOrWhiteSpace(nome.Text) || String.IsNullOrWhiteSpace(cognome.Text) || String.IsNullOrWhiteSpace(password.Text)) { displayError.Margin = new Thickness((width - 300) / 2, 70, (width - 300) / 2, 0); displayError.Text = "Compilare i campi"; displayError.IsVisible = true; } else { app = "{\"name\":\"" + nome.Text + "\",\"surname\":\"" + cognome.Text + "\",\"password\":\"" + Misc.MD5Hash(password.Text) + "\"}"; Task <string> task = RestService.post("/signup?type=autista", app); displayError.Margin = new Thickness((width - 300) / 2, 70, (width - 300) / 2, 0); displayError.TextColor = Color.DodgerBlue; displayError.Text = "Autotraportatore aggiunto"; displayError.IsVisible = true; nome.Text = ""; } } }