//Copy constructor public FoodItem(FoodItem fi) { Id = fi.Id; Name = fi.Name; Category = new List<FoodItemCategory>(); foreach (FoodItemCategory cat in fi.Category) { Category.Add(cat); } US_Serving = fi.US_Serving; Quantity = fi.Quantity; Unit = fi.Unit; Calories = fi.Calories; Protein = fi.Protein; Carbohydrates = fi.Carbohydrates; Sugar = fi.Sugar; Fat_sat = fi.Fat_sat; Fat_trans = fi.Fat_trans; Fat_poly = fi.Fat_poly; Cholesterol = fi.Cholesterol; Sodium = fi.Sodium; Type = new List<String>(); foreach (String s in fi.Type) { Type.Add(s); } }
private void Add_Click(object sender, RoutedEventArgs e) { Meal mealToAdd = App.MealViewModel.MealToAdd; if (mealToAdd == null) { mealToAdd = new Meal(); mealToAdd.MTime = (Meal.MealTime)mealTimePicker.SelectedItem; mealToAdd.Time = (DateTime)timePicker.Value; mealToAdd.FoodItems = new ObservableCollection<FoodItem>(); } ObservableCollection<FoodItem> fis = mealToAdd.FoodItems; FoodItem fi = new FoodItem((FoodItem)foodItemPicker.SelectedItem); fi.Quantity = Double.Parse(quantityTxt.Text); fis.Add(fi); App.MealViewModel.MealToAdd = mealToAdd; }