public async Task <IActionResult> Edit(int id, [Bind("BreakfastFoodID,BFName,BFCaloriePerOunce,BFGram,BFTotalCalorie,BFDbFoodID,BFUserID,BFDate")] BreakfastFood breakfastFood)
        {
            if (id != breakfastFood.BreakfastFoodID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                string date = breakfastFood.BFDate;
                try
                {
                    _context.Update(breakfastFood);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BreakfastFoodExists(breakfastFood.BreakfastFoodID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), "MealPlans", new { date = date }));
            }
            return(View(breakfastFood));
        }
        public async Task <IActionResult> Add(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var ChosenFood = await _context.Food.FirstOrDefaultAsync(m => m.FoodID == id);

            var PlannedFood = new BreakfastFood
            {
                BFName            = ChosenFood.Name,
                BFCaloriePerOunce = ChosenFood.CaloriePerOunce,
                BFDbFoodID        = ChosenFood.FoodID,
            };

            if (TempData.ContainsKey("date"))
            {
                DateTime tanggalDT = DateTime.Parse(TempData["date"].ToString());
                PlannedFood.BFDate = tanggalDT.ToString("yyyy-MM-dd");
            }
            else
            {
                PlannedFood.BFDate = DateTime.Now.ToString("yyyy-MM-dd");
            }

            if (PlannedFood == null)
            {
                return(NotFound());
            }

            return(View(PlannedFood));
        }
        public async Task <IActionResult> Add([Bind("BreakfastFoodID,BFName,BFCaloriePerOunce,BFGram,BFTotalCalorie,BFDbFoodID,BFUserID,BFDate")] BreakfastFood PlannedFood)
        {
            if (ModelState.IsValid)
            {
                ClaimsPrincipal currentUser   = this.User;
                var             currentUserID = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value;
                PlannedFood.BFUserID = currentUserID;

                string date = PlannedFood.BFDate;

                _context.Add(PlannedFood);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), "MealPlans", new { date = date }));
            }
            return(View(PlannedFood));
        }