public void DeleteIngredientLine(int ingredientLineID) { IngredientLine dbEntry = context.IngredientLine .FirstOrDefault(p => p.IngredientLineID == ingredientLineID); if (dbEntry != null) { System.Diagnostics.Debug.WriteLine("Achou ", ingredientLineID); context.IngredientLine.Remove(dbEntry); context.SaveChanges(); } }
public virtual void AddItem(Ingredient ingredient, int quantity) { IngredientLine line = lineCollection .Where(p => p.IngredientID == ingredient.IngredientID) .FirstOrDefault(); if (line == null) { lineCollection.Add(new IngredientLine { Quantity = quantity }); } else { line.Quantity += quantity; } }