public IActionResult AddNewWaste(Waste newWaste) { bool result = false; bool inventoryResult = inventoryDAO.DebitInventory(newWaste.inventoryId, newWaste.amountWasted); if (inventoryResult) { result = wasteDAO.RecordNewWaste(newWaste); } if (result) { return(Created("", result)); } else { return(BadRequest()); } }
public IActionResult AddNewSale(Sales newSale) { bool result = false; bool inventoryResult = inventoryDAO.DebitInventory(newSale.inventoryId, newSale.amountSold); if (inventoryResult) { result = salesDAO.RecordNewSale(newSale); } if (result) { return(Created("", result)); } else { return(BadRequest()); } }
public IActionResult AddNewLoss(Loss newLoss) { bool result = false; bool inventoryResult = inventoryDAO.DebitInventory(newLoss.inventoryId, newLoss.amountLost); if (inventoryResult) { result = lossDAO.RecordNewLoss(newLoss); } if (result) { return(Created("", result)); } else { return(BadRequest()); } }
public IActionResult UpdatePlan(Harvest someHarvest) { bool result = false; Harvest originalHarvest = harvestDAO.GetSpecificHarvest(someHarvest.harvestId); decimal inventoryAmountChange = originalHarvest.weight - someHarvest.weight; bool inventoryResult = inventoryDAO.DebitInventory(someHarvest.inventoryId, inventoryAmountChange); if (inventoryResult) { result = harvestDAO.UpdateHarvest(someHarvest); } if (result) { return(Ok("Update successful")); } else { return(BadRequest("Update failed")); } }