Example #1
0
        public async void eventClic(Object sender, EventArgs e)
        {
            BlockAndActive();

            //int variable = 0;
            String stMensaje = String.Empty;

            if (String.IsNullOrEmpty(emailEntry.Text))
            {
                stMensaje += "Ingrese Email, ";
            }
            if (String.IsNullOrEmpty(passwordEntry.Text))
            {
                stMensaje += "Ingrese Contraseña, ";
            }
            if (!String.IsNullOrEmpty(stMensaje))
            {
                BlockAndActive();
                await DisplayAlert("Alerta", stMensaje, "Ok");

                return;
            }

            //foreach(Usuario user in listUser)
            //{
            //if (user.stCorreo.Equals(emailEntry.Text) && user.stContraseña.Equals(passwordEntry.Text))
            //{

            //variable = 1;
            //}
            //};

            clsUsuarios clsUsuario = new clsUsuarios
            {
                inCodigo           = 0,
                stNombre           = ":v",
                stApellido         = ":v",
                stUsuaImagen       = "luego",
                inPuntuacionMaxima = 0,
                inTipo             = 0,
                stCorreo           = emailEntry.Text,
                stPassword         = passwordEntry.Text
            };
            string     url        = string.Format("{0}", "http://172.16.20.42/ApiCAC//api/Usuarios/validarUsuarios");
            Iservicios myServices = DependencyService.Get <Iservicios>();
            string     myObject   = await myServices.Login(clsUsuario);

            //string myObject = await myServices.newLogin(url,clsUsuario,Login.Methods.POST,Login.ContentType.JSON);
            //Boolean resp  = JsonConvert.DeserializeObject<Boolean>(myObject);

            if (myObject == null)
            {
                BlockAndActive();

                return;
            }
            if (myObject.Equals("true"))
            {
                BlockAndActive();

                await Navigation.PushAsync(new Mapa());

                Navigation.RemovePage(this);
                //mandar a la otra pagin
            }
            else
            {
                BlockAndActive();
                await DisplayAlert("Alerta", "Contraseña o Correo Incorrecta", "Ok");

                return;
            }
            //if(variable==0) await DisplayAlert("Alerta", "Contraseña o Correo Incorrecta", "Ok");
        }
Example #2
0
        public async void eventClicCrear(Object sender, EventArgs e)
        {
            String stMensaje = String.Empty;

            if (String.IsNullOrEmpty(NombreEntry.Text))
            {
                stMensaje += "Ingrese Nombre, ";
            }
            if (String.IsNullOrEmpty(ApellidoEntry.Text))
            {
                stMensaje += "Ingrese Apellido, ";
            }
            if (String.IsNullOrEmpty(CorreoEntry.Text))
            {
                stMensaje += "Ingrese Correo, ";
            }
            if (String.IsNullOrEmpty(ContraseñaEntry.Text))
            {
                stMensaje += "Ingrese Contraseña, ";
            }
            if (String.IsNullOrEmpty(CContraseñaEntry.Text))
            {
                stMensaje += "Ingrese la verificacion de la contraseña, ";
            }
            if (ContraseñaEntry.Text != CContraseñaEntry.Text)
            {
                stMensaje += "Las contraseñas no son iguales";
            }
            if (!String.IsNullOrEmpty(stMensaje))
            {
                await DisplayAlert("Alerta", stMensaje, "Ok");

                return;
            }

            clsUsuarios user = new clsUsuarios
            {
                stNombre   = NombreEntry.Text,
                stApellido = ApellidoEntry.Text,
                stCorreo   = CorreoEntry.Text,
                stPassword = ContraseñaEntry.Text
            };
            Iservicios myServices = DependencyService.Get <Iservicios>();
            string     respuesta  = await myServices.crearCuenta(user);

            if (respuesta.Equals("true"))
            {
                await DisplayAlert("Alerta", "Ya hay una cuenta con este correo", "Ok");

                return;
            }
            else if (respuesta.Equals("false"))
            {
                await DisplayAlert("Excelente!!!", "Su cuenta se ha creado con exito", "OK");

                NombreEntry.Text      = String.Empty;
                ApellidoEntry.Text    = String.Empty;
                CorreoEntry.Text      = String.Empty;
                ContraseñaEntry.Text  = String.Empty;
                CContraseñaEntry.Text = String.Empty;
            }
        }