コード例 #1
0
        //public IActionResult FindNutritionItem(string SearchString)
        //{
        //    return View();
        //}
        //[HttpPost]
        public async Task <IActionResult> FindNutritionItem([FromServices] NutritionixService nutritionixService, string SearchString)
        {
            // SearchString = "mcdouble";
            NutritionixFoodItem nutritionixFoodItem = await nutritionixService.GetSearchedNutritionItem(SearchString);

            SearchedFood foodReturned = new SearchedFood();

            foodReturned.Name        = nutritionixFoodItem.hits[0].fields.item_name;
            foodReturned.BrandName   = nutritionixFoodItem.hits[0].fields.brand_name;
            foodReturned.Calories    = (int)nutritionixFoodItem.hits[0].fields.nf_calories;
            foodReturned.ServingSize = nutritionixFoodItem.hits[0].fields.nf_serving_size_qty;

            return(View(foodReturned));
        }
コード例 #2
0
 public Health_EnthusiastController(ApplicationDbContext context, NutritionixService nutritionixService)
 {
     _context            = context;
     _nutritionixService = nutritionixService;
 }
コード例 #3
0
 public NutritionixController(ApplicationDbContext context, NutritionixService nutritionixService)
 {
     _context            = context;
     _nutritionixService = nutritionixService;
 }