예제 #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();
            }
        }
예제 #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();
        }
예제 #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);
            }
        }