示例#1
0
        private async void ClickRegistrarButton(object sender, EventArgs e)
        {
            JsonResponseInsert Result = await con.RegistraNuevoUsuario(User.Text, Pass.Text, Nombre.Text, Email.Text);


            if (Result.Transaccion != null)
            {
                if (Result.Transaccion.Operacion.Respuesta == "OK")
                {
                    //Se termina el registro del nuevo usuario y se le da acceso a la pagina principal
                    Aplicacion.App.Current.MainPage = new PaginaNavegadora();
                }
                else
                {
                    //Errores de bd (usuario ya existe , email ya existe etc .. )
                }
            }
        }
示例#2
0
        public async Task <JsonResponseInsert> RegistraNuevoUsuario(string Usuario, string Password, string Nombre, string Email)
        {
            var Url = new Uri(string.Format("http://esb.wisetrack.cl/BuscoProducto/Usuario", string.Empty));
            RegistroDeUsuario Usu = new RegistroDeUsuario(Usuario, Password, Nombre, Email);
            var json     = JsonConvert.SerializeObject(Usu);
            var content  = new StringContent(json, Encoding.UTF8, "application/json");
            var response = await client.PostAsync(Url, content);

            JsonResponseInsert Item;

            if (response.IsSuccessStatusCode)
            {
                var ContentResponse = await response.Content.ReadAsStringAsync();

                Item = JsonConvert.DeserializeObject <JsonResponseInsert>(ContentResponse);
            }
            else
            {
                Item = new JsonResponseInsert();
            }
            return(Item);
        }
示例#3
0
        private async void AccessToken(FacebookOAuthResult obj)
        {
            GraphApi api = new GraphApi(obj.AccessToken);
            //Declaro los parametros que me traigo desde facebook id , name , birthday , email , picture
            FacebookUser user = await api.Explorer <FacebookUser>("/me?fields=id,name,birthday,email,picture{url}");

            UsuarioJson User = await con.ConsultaExistenciaUsuario(user.id, user.id);

            if (User.Usuario == null)
            {
                // Si usuario es null entonces me registro
                JsonResponseInsert Result = await con.RegistraNuevoUsuario(user.id, user.id, user.name, user.email);

                //si el registro retorna null es porque no hay conexion
                if (Result.Transaccion != null)
                {
                    if (Result.Transaccion.Operacion.Respuesta != "NO")
                    {
                        // si es distinto a NO se registro bien asi que lo envio a la pagina principal
                        Aplicacion.App.Current.MainPage = new PaginaNavegadora();
                    }
                    else
                    {
                        // si retorna NO es por bd (error o condicionales no cumplidas )
                        // popup error de registro
                    }
                }
                else
                {
                    //Pupup Error de Registro atravez de facebook
                }
            }
            else
            {
                //el usuario ya existe en BD y facebook ya valido password asi que le doy acceso
                Aplicacion.App.Current.MainPage = new PaginaNavegadora();
            }
        }