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 = ""; } } }