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 Post([FromBody] Product product) { if (ProductDAO.Exists(product.Sku)) { return(BadRequest("The Sku is already in use!")); } foreach (Warehouse w in product.Inventory.Warehouses) { WarehouseDAO.CreateRecord(w, product.Sku); } ProductDAO.CreateRecord(product); return(Ok("Successfully inserted the new record")); }