public void Update(int itemId)
 {
     // Added Ingredients
     foreach (ItemIngredient itemIngredient in _itemIngredientsAdded)
     {
         itemIngredient.SetItemId(itemId);
         itemIngredient.Update();
         ItemIngredientAdjustment.Add(SessionManager.ActiveEmployee.Id,
                                      itemId, itemIngredient.IngredientId, null,
                                      itemIngredient.Amount, itemIngredient.MeasurementUnit);
     }
     // Changed Ingredients
     foreach (ItemIngredient itemIngredient in _itemIngredientsNeedingUpdate)
     {
         ItemIngredient original  = ItemIngredient.Get(itemIngredient.Id);
         double         oldAmount = UnitConversion.Convert(original.Amount, original.MeasurementUnit,
                                                           itemIngredient.MeasurementUnit);
         itemIngredient.Update();
         ItemIngredientAdjustment.Add(SessionManager.ActiveEmployee.Id,
                                      itemId, itemIngredient.IngredientId, oldAmount, itemIngredient.Amount,
                                      itemIngredient.MeasurementUnit);
     }
     // Removed Ingredients
     foreach (ItemIngredient itemIngredient in _itemIngredientsRemoved)
     {
         ItemIngredient.Delete(itemIngredient.Id);
         ItemIngredientAdjustment.Add(SessionManager.ActiveEmployee.Id,
                                      itemId, itemIngredient.IngredientId, itemIngredient.Amount, null,
                                      itemIngredient.MeasurementUnit);
     }
     _itemIngredientsAdded.Clear();
     _itemIngredientsNeedingUpdate.Clear();
     _itemIngredientsRemoved.Clear();
 }
 private ItemIngredient GetItemIngredient(int id,
                                          out bool cachedAdd, out bool cachedChange, out bool cachedRemove)
 {
     cachedAdd    = false;
     cachedChange = false;
     cachedRemove = false;
     foreach (ItemIngredient itemIngredient in
              _itemIngredientsAdded.Where(itemIngredient => itemIngredient.Id == id))
     {
         cachedAdd = true;
         return(itemIngredient);
     }
     foreach (ItemIngredient itemIngredient in
              _itemIngredientsNeedingUpdate.Where(itemIngredient => itemIngredient.Id == id))
     {
         cachedChange = true;
         return(itemIngredient);
     }
     foreach (ItemIngredient itemIngredient in
              _itemIngredientsRemoved.Where(itemIngredient => itemIngredient.Id == id))
     {
         cachedRemove = true;
         return(itemIngredient);
     }
     return(ItemIngredient.Get(id));
 }