private void logInTapped(object sender, EventArgs e)
 {
     if (String.IsNullOrWhiteSpace(nome.Text) || String.IsNullOrWhiteSpace(password.Text) || String.IsNullOrWhiteSpace(cognome.Text))
     {
         displayError.Margin    = new Thickness((width - 200) / 2, 10, (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=autista&name=" + nome.Text + "&surname=" + cognome.Text + "&password="******"\n\nbased " + task.Result);
         if (task.Result == "err 204")
         {
             displayError.Margin    = new Thickness((width - 200) / 2, 10, (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 mainAutotrasportatore());
         }
     }
 }
Beispiel #2
0
        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 = "";
                }
            }
        }