Ejemplo n.º 1
0
        public IActionResult Put(int sku, [FromBody] Product product)
        {
            if (sku <= 0)
            {
                return(BadRequest("Please inform a Sku!"));
            }

            if (!ProductDAO.Exists(sku))
            {
                return(BadRequest("The Sku is already in use!"));
            }

            WarehouseDAO.Delete(sku);

            foreach (Warehouse w in product.Inventory.Warehouses)
            {
                WarehouseDAO.CreateRecord(w, sku);
            }

            if (ProductDAO.Update(product))
            {
                return(Ok("Successfully updated the  record"));
            }

            return(BadRequest("Error while updating record!"));
        }
Ejemplo n.º 2
0
        public IActionResult Delete(int sku)
        {
            if (sku > 0)
            {
                if (ProductDAO.Delete(sku) && WarehouseDAO.Delete(sku))
                {
                    return(Ok("Successfully removed the  record"));
                }
            }

            return(BadRequest());
        }