private async void botonEliminar_Click(object sender, RoutedEventArgs e) { MessageDialog mensajeError = null; if (listBoxMetodosPago.SelectedIndex > -1) { ServicioAEIClient servicio = new ServicioAEIClient(); BufferUsuario.Usuario = await servicio.eliminarMetodoPagoAsync(metodos[listBoxMetodosPago.SelectedIndex], BufferUsuario.Usuario); if (BufferUsuario.Usuario != null) { popup.IsOpen = false; mensajeError = new MessageDialog("Operación exitosa"); mensajeError.ShowAsync(); } else { mensajeError = new MessageDialog("No se pudo realizar la operacion. Por favor comuniquese con [email protected]"); mensajeError.ShowAsync(); } } else { mensajeError = new MessageDialog("Por favor, seleccione uno de sus metodos de pago"); mensajeError.ShowAsync(); } }
private void busqueda_categoria(string calificacion) { ServicioAEIClient servicio = new ServicioAEIClient(); List <Producto> resultado; //Llamamos el metodo del servicio servicio.BusquedaProductoConCategoriaAsync(calificacion, this.textBuscador.Text); //Cuando se complete la llamada se disparara el evento servicio.BusquedaProductoConCategoriaCompleted += (s, a) => { resultado = a.Result; try { ProductosPage.busqueda = this.textBuscador.Text; ProductosPage.productos = resultado; ProductosPage.origen = 1; NavigationService.Navigate(new Uri("/ProductosPage.xaml", UriKind.Relative)); } catch (Exception ex) { Console.WriteLine(ex); } }; }
private void buttonBuscar_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(this.textBuscador.Text) == false) { //Declaramos el servicio ServicioAEIClient servicio = new ServicioAEIClient(); List <Producto> resultado; //Llamamos el metodo del servicio servicio.BusquedaProductoAsync(this.textBuscador.Text, 1, 5); //Cuando se complete la llamada se disparara el evento servicio.BusquedaProductoCompleted += (s, a) => { resultado = a.Result; try { ProductosPage.busqueda = this.textBuscador.Text; ProductosPage.productos = resultado; ProductosPage.origen = 0; NavigationService.Navigate(new Uri("/ProductosPage.xaml", UriKind.Relative)); } catch (Exception ex) { Console.WriteLine(ex); } }; } }
private void cambiarPagina(int operacion) { //Declaramos el servicio ServicioAEIClient servicio = new ServicioAEIClient(); List<Producto> resultado; //Llamamos el metodo del servicio if (operacion == 1) servicio.BusquedaProductoAsync(busqueda, pagina-1, 5); else servicio.BusquedaProductoAsync(busqueda, pagina+1, 5); //Cuando se complete la llamada se disparara el evento servicio.BusquedaProductoCompleted += (s, a) => { resultado = a.Result; try { if (productos[0].Id != resultado[0].Id) { productos = resultado; if (operacion == 1) pagina--; else pagina++; this.textNumeroPagina.Text = pagina + ""; } } catch (Exception ex) { Console.WriteLine(ex); } cargarProductos(); }; }
private async void botonEliminar_Click(object sender, RoutedEventArgs e) { MessageDialog mensajeError=null; if (listBoxMetodosPago.SelectedIndex > -1) { ServicioAEIClient servicio = new ServicioAEIClient(); BufferUsuario.Usuario = await servicio.eliminarMetodoPagoAsync(metodos[listBoxMetodosPago.SelectedIndex], BufferUsuario.Usuario); if (BufferUsuario.Usuario != null) { popup.IsOpen = false; mensajeError = new MessageDialog("Operación exitosa"); mensajeError.ShowAsync(); } else { mensajeError = new MessageDialog("No se pudo realizar la operacion. Por favor comuniquese con [email protected]"); mensajeError.ShowAsync(); } } else { mensajeError = new MessageDialog("Por favor, seleccione uno de sus metodos de pago"); mensajeError.ShowAsync(); } }
private void buttonBuscar_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(this.textBuscador.Text)==false) { //Declaramos el servicio ServicioAEIClient servicio = new ServicioAEIClient(); List<Producto> resultado; //Llamamos el metodo del servicio servicio.BusquedaProductoAsync(this.textBuscador.Text, 1, 5); //Cuando se complete la llamada se disparara el evento servicio.BusquedaProductoCompleted += (s, a) => { resultado = a.Result; try { ProductosPage.busqueda = this.textBuscador.Text; ProductosPage.productos = resultado; ProductosPage.origen = 0; NavigationService.Navigate(new Uri("/ProductosPage.xaml", UriKind.Relative)); } catch (Exception ex) { Console.WriteLine(ex); } }; } }
public ArticuloPivotPage() { InitializeComponent(); Menu.Children.Add(new MenuControl()); ServicioAEIClient servicio = new ServicioAEIClient(); cargarInformacionProducto(); }
private async void llenarComboCategoria() { comboCategoria.Items.Clear(); ServicioAEIClient servicioProducto = new ServicioAEIClient(); List<Categoria> listCategoria = await servicioProducto.BuscarTodasLasCategoriasAsync(); comboCategoria.Items.Add("Todas"); comboCategoria.SelectedIndex = 0; for (int categoria = 0; categoria < listCategoria.Count(); categoria++) { comboCategoria.Items.Add(listCategoria.ElementAt(categoria).Nombre); } }
private async void llenarComboCategoria() { comboCategoria.Items.Clear(); ServicioAEIClient servicioProducto = new ServicioAEIClient(); List <Categoria> listCategoria = await servicioProducto.BuscarTodasLasCategoriasAsync(); comboCategoria.Items.Add("Todas"); comboCategoria.SelectedIndex = 0; for (int categoria = 0; categoria < listCategoria.Count(); categoria++) { comboCategoria.Items.Add(listCategoria.ElementAt(categoria).Nombre); } }
private void calcularPaginas() { //Declaramos el servicio ServicioAEIClient servicio = new ServicioAEIClient(); //Llamamos el metodo del servicio servicio.calcularPaginaPorBusquedaAsync(busqueda, 5); //Cuando se complete la llamada se disparara el evento servicio.calcularPaginaPorBusquedaCompleted += (s, a) => { totalPaginas = a.Result; if (totalPaginas == 0.0) totalPaginas = 1.0; }; }
private async void botonLupa_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { MessageDialog mensajeError = new MessageDialog("Su búsqueda no retornó ningún resultado."); ServicioAEIClient servicioProducto = new ServicioAEIClient(); if (comboCategoria.SelectedIndex == 0) ListaProducto.ListaProductos = await servicioProducto.BusquedaProductoAplicacionAsync(textBoxBusqueda.Text); else ListaProducto.ListaProductos = await servicioProducto.BusquedaProductoConCategoriaAsync(comboCategoria.SelectedItem.ToString(), textBoxBusqueda.Text); if (ListaProducto.ListaProductos.Count() == 0) { mensajeError.ShowAsync(); } else cargarProductos(); }
private async void buttonEnviar_Click(object sender, RoutedEventArgs e) { //este codigo deberia verificarse contra la base de datos directamente? if (BufferUsuario.Usuario.CodigoActivacion != int.Parse(textCodigo.Text)) { MessageDialog mensajeError = new MessageDialog("El código de autorización no coincide"); mensajeError.ShowAsync(); } else { BufferUsuario.Usuario.Status = "A"; ServicioAEIClient servicio = new ServicioAEIClient(); int error = await servicio.modificarUsuarioAsync(BufferUsuario.Usuario); popup.IsOpen = false; } }
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 calcularPaginas() { //Declaramos el servicio ServicioAEIClient servicio = new ServicioAEIClient(); //Llamamos el metodo del servicio servicio.calcularPaginaPorBusquedaAsync(busqueda, 5); //Cuando se complete la llamada se disparara el evento servicio.calcularPaginaPorBusquedaCompleted += (s, a) => { totalPaginas = a.Result; if (totalPaginas == 0.0) { totalPaginas = 1.0; } }; }
private void cambiarPagina(int operacion) { //Declaramos el servicio ServicioAEIClient servicio = new ServicioAEIClient(); List <Producto> resultado; //Llamamos el metodo del servicio if (operacion == 1) { servicio.BusquedaProductoAsync(busqueda, pagina - 1, 5); } else { servicio.BusquedaProductoAsync(busqueda, pagina + 1, 5); } //Cuando se complete la llamada se disparara el evento servicio.BusquedaProductoCompleted += (s, a) => { resultado = a.Result; try { if (productos[0].Id != resultado[0].Id) { productos = resultado; if (operacion == 1) { pagina--; } else { pagina++; } this.textNumeroPagina.Text = pagina + ""; } } catch (Exception ex) { Console.WriteLine(ex); } cargarProductos(); }; }
private void botonBorrar_Click(object sender, System.Windows.RoutedEventArgs e) { ServicioAEIClient servicio = new ServicioAEIClient(); servicio.borrarDetalleCarritoAsync(BufferUsuario.Usuario, BufferUsuario.Usuario.Carrito.Productos.ElementAt(indexProducto)); servicio.borrarDetalleCarritoCompleted += (s, a) => { BufferUsuario.Usuario = a.Result; try { MessageBox.Show("Se elimino el producto del carrito"); (Application.Current.RootVisual as PhoneApplicationFrame).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); } }; }
private async void botonLupa_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { MessageDialog mensajeError = new MessageDialog("Su búsqueda no retornó ningún resultado."); ServicioAEIClient servicioProducto = new ServicioAEIClient(); if (comboCategoria.SelectedIndex == 0) { ListaProducto.ListaProductos = await servicioProducto.BusquedaProductoAplicacionAsync(textBoxBusqueda.Text); } else { ListaProducto.ListaProductos = await servicioProducto.BusquedaProductoConCategoriaAsync(comboCategoria.SelectedItem.ToString(), textBoxBusqueda.Text); } if (ListaProducto.ListaProductos.Count() == 0) { mensajeError.ShowAsync(); } else { cargarProductos(); } }
private void botonComprar_Click(object sender, System.Windows.RoutedEventArgs e) { if (BufferUsuario.Usuario.MetodosPago == null && BufferUsuario.Usuario.MetodosPago.ElementAt(0) == null) { MessageBox.Show("Disculpe, no tiene metodos de pago registrados"); return; } if (BufferUsuario.Usuario.Direcciones == null && BufferUsuario.Usuario.Direcciones.ElementAt(0) == null) { MessageBox.Show("Disculpe, no tiene direcciones registradas"); return; } ServicioAEIClient servicioAei = new ServicioAEIClient(); servicioAei.checkoutAsync(BufferUsuario.Usuario.MetodosPago.ElementAt(0), BufferUsuario.Usuario.Direcciones.ElementAt(0), BufferUsuario.Usuario); servicioAei.checkoutCompleted += (s, a) => { BufferUsuario.Usuario = a.Result; MessageBox.Show("Su compra fue procesada exitosamente"); }; listBoxProductos.Items.Clear(); }
private void buttonComprar_Click(object sender, System.Windows.RoutedEventArgs e) { ServicioAEIClient servicioAei = new ServicioAEIClient(); if (producto.Cantidad == 0) { MessageBox.Show("Este articulo esta agotado, buscaremos en otra tienda"); return; } servicioAei.checkearProductoCarritoAsync(BufferUsuario.Usuario, producto); servicioAei.checkearProductoCarritoCompleted += (s, a) => { bool chequear = a.Result; if (chequear) { MessageBox.Show("Ya posee este producto en el carrito"); return; } ConfirmacionPage.producto = producto; NavigationService.Navigate(new Uri("/ConfirmacionPage.xaml", UriKind.Relative)); }; }
private void busqueda_categoria(string calificacion) { ServicioAEIClient servicio = new ServicioAEIClient(); List<Producto> resultado; //Llamamos el metodo del servicio servicio.BusquedaProductoConCategoriaAsync(calificacion, this.textBuscador.Text); //Cuando se complete la llamada se disparara el evento servicio.BusquedaProductoConCategoriaCompleted += (s, a) => { resultado = a.Result; try { ProductosPage.busqueda = this.textBuscador.Text; ProductosPage.productos = resultado; ProductosPage.origen = 1; NavigationService.Navigate(new Uri("/ProductosPage.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; }