public void DeleteOneQuantity(int id) { IngredientQuantity deletedQuantity = _inventoryEntities.IngredientQuantities.FirstOrDefault(i => i.ID == id); if (deletedQuantity != null) { _inventoryEntities.IngredientQuantities.Remove(deletedQuantity); _inventoryEntities.SaveChanges(); } }
public void CreateQuantity(IngredientQuantityModel newIngredientQuantity) { //convert ingredientQuantityModel to a quantity for the database IngredientQuantity dbIngredientQuantity = new IngredientQuantity(); dbIngredientQuantity.ID = newIngredientQuantity.ID; dbIngredientQuantity.IngredientID = newIngredientQuantity.IngredientID; dbIngredientQuantity.Amount = newIngredientQuantity.Amount; dbIngredientQuantity.Unit = newIngredientQuantity.Unit; _inventoryEntities.IngredientQuantities.Add(dbIngredientQuantity); _inventoryEntities.SaveChanges(); }
public IngredientQuantityModel GetIngredientQuantity(int id) { IngredientQuantity quantity = _inventoryEntities.IngredientQuantities.FirstOrDefault(i => i.ID == id); if (quantity != null) { IngredientQuantityModel quantityModel = new IngredientQuantityModel(quantity.ID, quantity.IngredientID, quantity.Amount, quantity.Unit); return(quantityModel); } else { return(null); } }