private async void botonEliminar_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            BufferUsuario.Usuario = await servicioAei.ConsultarUsuarioAsync(BufferUsuario.Usuario.Email);

            BufferUsuario.Usuario = await servicioAei.borrarDetalleCarritoAsync(BufferUsuario.Usuario, BufferUsuario.Usuario.Carrito.Productos.ElementAt(indexProducto));

            padre.cargarCarrito();
        }
        public async void getToken(string code)
        {
            var form = new Dictionary <string, string>
            {
                { "code", code },
                { "client_id", "484156375778.apps.googleusercontent.com" },
                { "client_secret", "PH0hTcYgaOvpXKpeCyWW6690" },
                { "redirect_uri", "urn:ietf:wg:oauth:2.0:oob" },
                { "grant_type", "authorization_code" },
            };

            var content  = new FormUrlEncodedContent(form);
            var client   = new HttpClient();
            var response = await client.PostAsync("https://accounts.google.com/o/oauth2/token", content);

            var json = await response.Content.ReadAsStringAsync();

            JObject respuestaJson = JObject.Parse(json);

            token = (string)respuestaJson.SelectToken("access_token");

            var respuesta = await client.GetAsync("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + token);

            json = await respuesta.Content.ReadAsStringAsync();

            respuestaJson = JObject.Parse(json);
            string email = (string)respuestaJson.SelectToken("email");

            ServicioAEIClient servicioUsuario = new ServicioAEIClient();

            BufferUsuario.Usuario = await servicioUsuario.ConsultarUsuarioAsync(email);

            if (BufferUsuario.Usuario == null)
            {
                MessageDialog mensajeError = new MessageDialog("Usted no esta registrado en nuestro sistema con el correo electonico " + email +
                                                               " intente de nuevo con correo valido o registrese");
                mensajeError.ShowAsync();
                botonSender.Content = "Ingresar";
            }
            else
            {
                botonSender.Content = "Salir";
            }

            return;
        }
        private void botonComprar_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            detalleCompra.Cantidad = cantidadProducto;
            detalleCompra.Producto = producto;
            detalleCompra.Monto    = producto.Precio;

            servicioAei.agregarCarritoAsync(BufferUsuario.Usuario, detalleCompra);

            servicioAei.agregarCarritoCompleted += (s, a) =>
            {
                BufferUsuario.Usuario = a.Result;
                MessageBox.Show("Se agrego el poducto a su carrito con exito");
                servicioAei.ConsultarUsuarioAsync(BufferUsuario.Usuario.Email);
                servicioAei.ConsultarUsuarioCompleted += (t, b) =>
                {
                    BufferUsuario.Usuario = b.Result;
                    NavigationService.Navigate(new Uri("/StorePage.xaml", UriKind.Relative));
                };
            };
        }
        private void  Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //Declaramos el servicio
            ServicioAEIClient servicio = new ServicioAEIClient();
            //Llamamos el metodo del servicio
            servicio.ConsultarUsuarioAsync("*****@*****.**");

            //Cuando se complete la llamada se disparara el evento
            servicio.ConsultarUsuarioCompleted += (s, a) =>
            {
                BufferUsuario.Usuario = a.Result;
                try
                {
                    NavigationService.Navigate(new Uri("/StorePage.xaml", UriKind.Relative));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            };
        }
        private void  Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //Declaramos el servicio
            ServicioAEIClient servicio = new ServicioAEIClient();

            //Llamamos el metodo del servicio
            servicio.ConsultarUsuarioAsync("*****@*****.**");

            //Cuando se complete la llamada se disparara el evento
            servicio.ConsultarUsuarioCompleted += (s, a) =>
            {
                BufferUsuario.Usuario = a.Result;
                try
                {
                    NavigationService.Navigate(new Uri("/StorePage.xaml", UriKind.Relative));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            };
        }
        public async void getToken(string code)
        {

            var form = new Dictionary<string, string>
            {
            {"code", code},
            {"client_id", "484156375778.apps.googleusercontent.com"},
            {"client_secret", "PH0hTcYgaOvpXKpeCyWW6690"},
            {"redirect_uri", "urn:ietf:wg:oauth:2.0:oob"},
            {"grant_type", "authorization_code"},
            };
               
            var content = new FormUrlEncodedContent(form);               
            var client = new HttpClient(); 
            var response = await client.PostAsync("https://accounts.google.com/o/oauth2/token", content);
            var json = await response.Content.ReadAsStringAsync();
 
            JObject respuestaJson = JObject.Parse(json);
            token = (string)respuestaJson.SelectToken("access_token");

            var respuesta = await client.GetAsync("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + token);
            json = await respuesta.Content.ReadAsStringAsync();
            respuestaJson = JObject.Parse(json);
            string email = (string)respuestaJson.SelectToken("email");

            ServicioAEIClient servicioUsuario = new ServicioAEIClient();
            BufferUsuario.Usuario = await servicioUsuario.ConsultarUsuarioAsync(email);
            if (BufferUsuario.Usuario == null)
            {
                MessageDialog mensajeError = new MessageDialog("Usted no esta registrado en nuestro sistema con el correo electonico "+email+
                                            " intente de nuevo con correo valido o registrese");
                mensajeError.ShowAsync();
                botonSender.Content = "Ingresar";
            }
            else
             botonSender.Content = "Salir";

            return;
        }