Exemple #1
0
        public async Task DeletePackIconClickAsync(Productos producto)
        {
            if (producto != null)
            {
                if (producto.ImgProducto != null)
                {
                    string[] rutaImagen = producto.ImgProducto.Split('/');
                    string   nomFoto    = rutaImagen[rutaImagen.Length - 1];
                    StorageService.DeleteImageStorage(nomFoto, "imagenesproductos");
                }
                bool response = await ApiRestService.DeleteProducto(producto.IdProducto);

                if (response)
                {
                    MessageBox.Show("Producto eliminado correctamente", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                    ProductosList.Remove(producto);
                    await ApiRestService.RunAsync();

                    ApiRestService.Refresh();
                }
                else
                {
                    MessageBox.Show("No se ha podido eliminar el producto", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Debes seleccionar un producto para eliminarlo", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #2
0
        public async Task ModificarTransportistaExecutedAsync()
        {
            bool response = await ApiRestService.PutTransportista(Transportista);

            if (response)
            {
                MessageBox.Show("Transportista modificado correctamente", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                await ApiRestService.RunAsync();

                ApiRestService.Refresh();
            }
            else
            {
                MessageBox.Show("No se ha podido modificar el transportista", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public async Task RegistrarTransportistaExecutedAsync(string nombreEmpresa, string numeroTelefono)
        {
            Transportistas transportistas = new Transportistas(nombreEmpresa, numeroTelefono);
            bool           response       = await ApiRestService.PostTransportista(transportistas);

            if (response)
            {
                MessageBox.Show("Transportisa registrado correctamente", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                await ApiRestService.RunAsync();

                ApiRestService.Refresh();
            }
            else
            {
                MessageBox.Show("No se ha podido registrar el transportista", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #4
0
        public async Task CrearCategoriaCommandExecutedAsync(string nombreCat, string descripcionCat, ImageSource imagen)
        {
            Categoria categoria = new Categoria(descripcionCat, ImageSourceProp, nombreCat);

            byte[] stream = StorageService.ImageSourceToBytes(new PngBitmapEncoder(), imagen);
            string url    = StorageService.UploadFileToStorage(stream, NomFichero, "imagenescategorias");

            categoria.ImgCategoria = url;
            bool response = await ApiRestService.PostCategoria(categoria);

            if (response)
            {
                MessageBox.Show("Se ha creado la categoria correctamente", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                await ApiRestService.RunAsync();

                ApiRestService.Refresh();
            }
            else
            {
                MessageBox.Show("No se ha podido crear la categoria ", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public async Task DeletePackIconClickAsync(Categoria categoria)
        {
            if (categoria.ImgCategoria != null)
            {
                string[] rutaImagen = categoria.ImgCategoria.Split('/');
                string   nomFoto    = rutaImagen[rutaImagen.Length - 1];
                StorageService.DeleteImageStorage(nomFoto, "imagenescategorias");
            }
            bool response = await ApiRestService.DeleteCategoria(categoria.IdCategoria);

            if (response)
            {
                MessageBox.Show("Categoria eliminada correctamente", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                Categorias.Remove(categoria);
                await ApiRestService.RunAsync();

                ApiRestService.Refresh();
            }
            else
            {
                MessageBox.Show("No se ha podido eliminar la categoria", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public async Task CrearProductoCommandExecutedAsync(string nomProducto, string descProducto, string especificaciones, int idCategoria, float precio, ImageSource imageSource, int disponible, int descuento)
        {
            Productos producto = new Productos(nomProducto, descProducto, especificaciones, idCategoria, precio, disponible);

            producto.Descuento = descuento;
            byte[] stream = StorageService.ImageSourceToBytes(new PngBitmapEncoder(), imageSource);
            string url    = StorageService.UploadFileToStorage(stream, NomFichero, "imagenesproductos");

            producto.ImgProducto = url;
            bool response = await ApiRestService.PostProducto(producto);

            if (response)
            {
                await ApiRestService.RunAsync();

                ApiRestService.Refresh();
                MessageBox.Show("Se ha creado el producto correctamente", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show("No se ha podido crear el producto", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public async Task ModificarCategoriaExecutedAsync(Categoria categoria, ImageSource imagen)
        {
            if (NomFotoProp != null)
            {
                string[] rutaImagen = categoria.ImgCategoria.Split('/');
                string   nomFoto    = rutaImagen[rutaImagen.Length - 1];
                StorageService.DeleteImageStorage(nomFoto, "imagenescategorias");
                byte[] imagenBytes = StorageService.ImageSourceToBytes(new PngBitmapEncoder(), imagen);
                categoria.ImgCategoria = StorageService.UploadFileToStorage(imagenBytes, NomFotoProp, "imagenescategorias");
            }
            bool response = await ApiRestService.PutCategoria(categoria);

            if (response)
            {
                MessageBox.Show("Categoria actualizada correctamente", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                await ApiRestService.RunAsync();

                ApiRestService.Refresh();
            }
            else
            {
                MessageBox.Show("No se ha podido actualizar la categoria", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public MainWindowVistaModelo()
 {
     ApiRestService.RunAsync();
 }