Example #1
0
        public FoodItem(ObjectId id)
        {
            var item = App.FoodItemCollection.Find(i => i.Id.Equals(id)).Limit(1).FirstOrDefaultAsync().Result;

            Id         = item.Id;
            BrandName  = item.BrandName;
            FoodName   = item.FoodName;
            Nutrition  = new Nutrition(item.Nutrition);
            FoodTypeId = item.FoodTypeId;
            FoodType   = (FoodType)item.FoodTypeId;
        }
Example #2
0
 public Nutrition(Nutrition nutrition)
 {
     Calories          = nutrition.Calories;
     TotalFat          = nutrition.TotalFat;
     SaturatedFat      = nutrition.SaturatedFat;
     TransFat          = nutrition.TransFat;
     Cholesterol       = nutrition.Cholesterol;
     Sodium            = nutrition.Sodium;
     TotalCarbohydrate = nutrition.TotalCarbohydrate;
     DietaryFiber      = nutrition.DietaryFiber;
     TotalSugars       = nutrition.TotalSugars;
     AddedSugars       = nutrition.AddedSugars;
     Protein           = nutrition.Protein;
     VitaminD          = nutrition.VitaminD;
     Calcium           = nutrition.Calcium;
     Iron        = nutrition.Iron;
     Potassium   = nutrition.Potassium;
     ServingSize = nutrition.ServingSize;
 }
Example #3
0
 public FoodItem(string brandName, string foodName)
 {
     try
     {
         var item = App.FoodItemCollection
                    .Find(i => i.FoodName.Equals(foodName) && i.BrandName.Equals(brandName)).Limit(1).ToListAsync()
                    .Result.ElementAt(0);
         Id         = item.Id;
         FoodName   = item.FoodName;
         BrandName  = item.BrandName;
         Nutrition  = new Nutrition(item.Nutrition);
         FoodTypeId = item.FoodTypeId;
         FoodType   = (FoodType)item.FoodTypeId;
     }
     catch (Exception)
     {
         throw new Exception("Food item " + brandName + " " + foodName + " could not be found.");
     }
 }