public async Task <IActionResult> Edit(int id, [Bind("TakenActivityID,TAName,TACalorieBurnedPerMinute,TAMinute,TATotalCaloriBurned,TADate,TADbID,TAUserID")] TakenActivity takenActivity)
        {
            if (id != takenActivity.TakenActivityID)
            {
                return(NotFound());
            }

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

            var ChosenActivity = await _context.Activity.FirstOrDefaultAsync(m => m.ActivityID == id);

            var PlannedActivity = new TakenActivity
            {
                TAName = ChosenActivity.ActivityName,
                TACalorieBurnedPerMinute = ChosenActivity.CalorieBurnedPerMinute,
                TADbID = ChosenActivity.ActivityID
            };

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

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

            return(View(PlannedActivity));
        }
        public async Task <IActionResult> Add([Bind("TakenActivityID,TAName,TACalorieBurnedPerMinute,TAMinute,TATotalCaloriBurned,TADate,TADbID,TAUserID")] TakenActivity takenActivity)
        {
            if (ModelState.IsValid)
            {
                ClaimsPrincipal currentUser   = this.User;
                var             currentUserID = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value;
                takenActivity.TAUserID = currentUserID;

                string date = takenActivity.TADate;
                _context.Add(takenActivity);
                await _context.SaveChangesAsync();

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