Exemplo n.º 1
0
 public void UpdateNutrients(NutrientsPerMeal newNutrients)
 {
     SqlHelper.ExecuteNonQuery(cs, "UpdateNutrients",
                               newNutrients.MealId,
                               newNutrients.MealName,
                               newNutrients.PercentCarbs,
                               newNutrients.PercentFat,
                               newNutrients.PercentProtein,
                               newNutrients.PercentCalorie);
 }
Exemplo n.º 2
0
        private IngredientViewModel GenerateIngredientViewModel(int typeId, NutrientsPerMeal npm, double userCalories)
        {
            var ing   = repo.GetRandomIngredient(typeId);
            var units = repo.GetUnitsOfMesurement(ing.Id);

            var ingViewModel = new IngredientViewModel();

            ingViewModel.BindIngredient(ing);
            ingViewModel.BaseUnitEnergy = units;

            var calorieForType = npm.GetCalorieForType(ingViewModel.Type, userCalories);

            ingViewModel.FillCalculatedEnergyList(calorieForType);

            return(ingViewModel);
        }
Exemplo n.º 3
0
        public IList <NutrientsPerMeal> GetNutrientsPerMeal(int noOfMeals)
        {
            ds = SqlHelper.ExecuteDataset(cs, "getNutrientsPerMeal", noOfMeals);
            IList <NutrientsPerMeal> nutrients = new List <NutrientsPerMeal>();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                var meal = new NutrientsPerMeal();

                meal.PercentCarbs   = double.Parse(row["PercentageOfCarbs"].ToString());
                meal.PercentFat     = double.Parse(row["PercentageOfFat"].ToString());
                meal.PercentProtein = double.Parse(row["PercentageOfProtein"].ToString());
                meal.MealId         = (int)row["IDMealName"];
                meal.MealName       = row["Name"].ToString();
                meal.OfMeals        = int.Parse(row["OfMeals"].ToString());
                meal.PercentCalorie = double.Parse(row["PercentageOfCal"].ToString());

                nutrients.Add(meal);
            }
            return(nutrients);
        }