public void UpdateNutrients(NutrientsPerMeal newNutrients) { SqlHelper.ExecuteNonQuery(cs, "UpdateNutrients", newNutrients.MealId, newNutrients.MealName, newNutrients.PercentCarbs, newNutrients.PercentFat, newNutrients.PercentProtein, newNutrients.PercentCalorie); }
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); }
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); }