Esempio n. 1
0
    public void UpdateStockSize(int id, int productId, int sizeId, int stock)
    {
        if (id < 1 || productId < 1 || sizeId < 1 || stock < 0)
        {
            throw new Exception("No es posible actualizar el Stock, los valores no son válidos");
        }

        StockSizesDAO dao             = new StockSizesDAO();
        StockSize     updateStockSize = dao.GetStockSize(id);

        if (updateStockSize != null)
        {
            updateStockSize.productId = productId;
            updateStockSize.sizeId    = sizeId;
            updateStockSize.stock     = stock;
            int result = dao.UpdateStockSize(updateStockSize);
            if (result < 1)
            {
                throw new Exception("No es posible actualizarel Stock");
            }
        }
        else
        {
            throw new Exception("El id del Stock a actualizar no es válido");
        }
    }
Esempio n. 2
0
    public void DeleteStockSize(int id)
    {
        StockSizesDAO dao             = new StockSizesDAO();
        StockSize     deleteStockSize = dao.GetStockSize(id);

        if (deleteStockSize != null)
        {
            int result = dao.DeleteStockSize(deleteStockSize);
            if (result < 1)
            {
                throw new Exception("No es posible eliminar el Stock");
            }
        }
        else
        {
            throw new Exception("El id del Stock a eliminar no es válido");
        }
    }