public FoodItem Add(FoodItem toAdd) { int newId = !GetAll().Any() ? 1 : GetAll().Max(x => x.Id) + 1; toAdd.Id = newId; _foods.Add(newId, toAdd); return toAdd; }
public FoodItem Update(FoodItem toUpdate) { FoodItem single = GetSingle(toUpdate.Id); if (single == null) { return null; } _foods[single.Id] = toUpdate; return toUpdate; }