Beispiel #1
0
        /**
         * AgregarItem (): agrega un artículo a la compra
         */
        public String AgregarItem(int productoID)
        {
            String mensaje = "";
            // Crear un nuevo artículo para agregar al carrito
            ViewModelInventarioDetalle nuevoItem = new ViewModelInventarioDetalle(productoID);

            // Si este artículo ya existe en lista de libros, aumente la Cantidad
            // De lo contrario, agregue el nuevo elemento a la lista
            if (nuevoItem != null)
            {
                if (Items.Exists(x => x.id == productoID))
                {
                    ViewModelInventarioDetalle item = Items.Find(x => x.id == productoID);
                    item.totalStock++;
                }
                else
                {
                    nuevoItem.totalStock = 1;
                    Items.Add(nuevoItem);
                }
                mensaje = SweetAlertHelper.Mensaje("Orden producto", "Producto agregado a la orden", SweetAlertMessageType.success);
            }
            else
            {
                mensaje = SweetAlertHelper.Mensaje("Orden producto", "El producto solicitado no existe", SweetAlertMessageType.warning);
            }
            return(mensaje);
        }
Beispiel #2
0
        /**
         * SetItemCantidad(): cambia la Cantidad de un artículo en el carrito
         */
        public void SetItemCantidad(int idProducto, int Cantidad)
        {
            String mensaje = "";
            // Si estamos configurando la Cantidad a 0, elimine el artículo por completo
            ViewModelInventarioDetalle actualizarItem = new ViewModelInventarioDetalle(idProducto);

            if (Cantidad <= actualizarItem.Producto.totalStock)
            {
                if (Cantidad <= 0)
                {
                    EliminarItem(idProducto);
                }
                else
                {
                    // Encuentra el artículo y actualiza la Cantidad
                    if (Items.Exists(x => x.id == idProducto))
                    {
                        ViewModelInventarioDetalle item = Items.Find(x => x.id == idProducto);
                        item.totalStock = Cantidad;
                    }
                }
            }
        }