コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("TherapySessionGoalId,GoalId,TherapySessionId")] TherapySessionGoal therapySessionGoal)
        {
            if (id != therapySessionGoal.TherapySessionGoalId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(therapySessionGoal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TherapySessionGoalExists(therapySessionGoal.TherapySessionGoalId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GoalId"]           = new SelectList(_context.Goals, "GoalId", "Description", therapySessionGoal.GoalId);
            ViewData["TherapySessionId"] = new SelectList(_context.TherapySessions, "TherapySessionId", "Note", therapySessionGoal.TherapySessionId);
            return(View(therapySessionGoal));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("TherapySessionGoalId,GoalId,TherapySessionId")] TherapySessionGoal therapySessionGoal)
        {
            if (ModelState.IsValid)
            {
                _context.Add(therapySessionGoal);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GoalId"]           = new SelectList(_context.Goals, "GoalId", "Description", therapySessionGoal.GoalId);
            ViewData["TherapySessionId"] = new SelectList(_context.TherapySessions, "TherapySessionId", "Note", therapySessionGoal.TherapySessionId);
            return(View(therapySessionGoal));
        }