public static List <NutritionFact> GetDefaultNutritionFacts() { List <NutritionFact> t = new List <NutritionFact>(); foreach (Nutrient n in Enum.GetValues(typeof(Nutrient))) { t.Add(NutritionFact.Create(n)); } return(t); }
public void AddOrChangeDeclaration(Nutrient nutrient, int value) { var fact = NutritionFacts.FirstOrDefault(f => f.Nutrient == nutrient); if (fact == null) { fact = NutritionFact.Create(nutrient, value); NutritionFacts.Add(fact); } else { foreach (var f in NutritionFacts.Where(i => i.Nutrient == nutrient)) { f.ChangeValue(value); } } }