Exemplo n.º 1
0
        public void DeleteOneQuantity(int id)
        {
            IngredientQuantity deletedQuantity = _inventoryEntities.IngredientQuantities.FirstOrDefault(i => i.ID == id);

            if (deletedQuantity != null)
            {
                _inventoryEntities.IngredientQuantities.Remove(deletedQuantity);
                _inventoryEntities.SaveChanges();
            }
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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);
            }
        }