public async Task <IActionResult> Edit(string id, [Bind("UserId,TherapyId")] User_Therapy user_Therapy)
        {
            if (id != user_Therapy.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user_Therapy);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!User_TherapyExists(user_Therapy.UserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewData["UserId"]    = new SelectList(_context.Users, "Id", "Full_Name", user_Therapy.UserId);
            ViewData["TherapyId"] = new SelectList(_context.Therapies, "Id", "Therapy_Name", user_Therapy.TherapyId);
            return(View(user_Therapy));
        }
        public async Task <IActionResult> Create([Bind("UserId,TherapyId")] User_Therapy user_Therapy)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user_Therapy);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["UserId"]    = new SelectList(_context.Users, "Id", "Full_Name", user_Therapy.UserId);
            ViewData["TherapyId"] = new SelectList(_context.Therapies, "Id", "Therapy_Name", user_Therapy.TherapyId);
            return(View(user_Therapy));
        }
Exemplo n.º 3
0
 public void Update(User_Therapy user_therapy)
 {
     _context.Update(user_therapy);
 }
Exemplo n.º 4
0
 public void Delete(User_Therapy user_therapy)
 {
     _context.Remove(user_therapy);
 }
Exemplo n.º 5
0
 public void Add(User_Therapy user_therapy)
 {
     _context.Add(user_therapy);
 }