Beispiel #1
0
        public void SaveNutritionsTable()
        {
            log.InfoFormat("[SaveNutritionsTable]");
            using (Restaurants restaurantsDb = new Restaurants())
            {
                MongoEntityRepositoryBase<NutritionType> basicData =
                                            new MongoEntityRepositoryBase<NutritionType>(restaurantsDb.DB);

                using (usda_nutritionEntities context = new usda_nutritionEntities())
                {
                    var nutrtition = context.NUTR_DEF.ToList();
                    List<NutritionType> nutList = new List<NutritionType>();
                    foreach (var item in nutrtition)
                    {
                        log.InfoFormat("[SaveNutritionsTable] Loop: Nutr_No={0}, NutrDesc={1}.", item.Nutr_No, item.NutrDesc);

                        Spontaneous.DataModel.Foods.NutritionType tempNutrition = new Spontaneous.DataModel.Foods.NutritionType()
                        {
                            USDA_Nutr_No = int.Parse(item.Nutr_No),

                            Units = item.Units,
                            Tagname = item.Tagname != null ? item.Tagname : "",
                            NutrDesc = item.NutrDesc,
                            Num_Dec = item.Num_Dec
                            //SR_Order = int.Parse(item.SR_Order.ToString()),
                        };

                        nutList.Add(tempNutrition);
                        basicData.Add(tempNutrition);

                    }
                    Console.Write("After NutritionType copy loop.\n");
                }
            }
        }
Beispiel #2
0
        public void SaveFoodTable()
        {
            log.InfoFormat("[SaveFoodTable].");
            try
            {
                using (Restaurants restaurantsDb = new Restaurants())
                {
                    MongoEntityRepositoryBase<Ingredient> basicData =
                                                new MongoEntityRepositoryBase<Ingredient>(restaurantsDb.DB);

                    using (usda_nutritionEntities context = new usda_nutritionEntities())
                    {
                        var food_groups = context.FD_GROUP.ToList();
                        var weigts = context.WEIGHT.ToList();
                        var foods = context.FOOD_DES.ToList();
                        foreach (var item in foods)
                        {
                            Spontaneous.DataModel.Ingredient ingredient = FoodDesToIngredient(item, food_groups);
                            if(ingredient != null) basicData.Add(ingredient);
                        }
                        Console.Write("After Food copy loop.\n");
                    }
                }
            }
            catch (Exception e)
            {
                log.ErrorFormat("[SaveFoodTable] Exception={0}.", e);
            }
        }