Example #1
0
        private async void logBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Usuario user = await ConectorUsuario.LogIn(userBox.Text, passBox.Password);

                this.Frame.Navigate(typeof(MainPage), user);
                //si devuelve los datos abrimos el main
            }
            catch (Exception e1)
            {
                var dialog = new MessageDialog("Nombre de usuario o contraseƱa invalida.");
                await dialog.ShowAsync();

                System.Diagnostics.Debug.WriteLine(e1.Message);
            }
        }
Example #2
0
        private async void clickLogIn(object sender, EventArgs e)
        {
            /*
             * Intent intent = new Intent(this, typeof(MainActivity));
             * //intent.PutExtra("usuario", user.id);
             * StartActivity(intent);
             */
            userTxt.Enabled     = false;
            passwordTxt.Enabled = false;
            registerBtn.Enabled = false;
            logInBtn.Enabled    = false;
            reg2Btn.Enabled     = false;
            cancelBtn.Enabled   = false;
            try
            {
                Toast errorLogIn = Toast.MakeText(this, "Aguarde un momento por favor", ToastLength.Long);
                errorLogIn.Show();
                Usuario user = await ConectorUsuario.LogIn(userTxt.Text, passwordTxt.Text);

                Intent intent = new Intent(this, typeof(MainActivity));

                intent.PutExtra("username", user.username);
                intent.PutExtra("access_token", user.access_token);
                intent.PutExtra("nombre", user.nombre);
                intent.PutExtra("roles", user.roles);
                intent.PutExtra("id_user", user.id_user);

                StartActivity(intent);
            }
            catch (Exception e1)
            {
                Toast errorLogIn = Toast.MakeText(this, "Compruebe que el mail y el password sean correctos", ToastLength.Short);
                System.Diagnostics.Debug.WriteLine(e1.Message);
                errorLogIn.Show();
            }
            userTxt.Enabled     = true;
            passwordTxt.Enabled = true;
            registerBtn.Enabled = true;
            logInBtn.Enabled    = true;
            reg2Btn.Enabled     = true;
            cancelBtn.Enabled   = true;
        }