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!")); }
public IActionResult Delete(int sku) { if (sku > 0) { if (ProductDAO.Delete(sku) && WarehouseDAO.Delete(sku)) { return(Ok("Successfully removed the record")); } } return(BadRequest()); }