예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("EstudanteId,DisciplinaId")] EstudanteDisciplina estudanteDisciplina)
        {
            if (id != estudanteDisciplina.EstudanteId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(estudanteDisciplina);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EstudanteDisciplinaExists(estudanteDisciplina.EstudanteId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EstudanteId"] = new SelectList(_context.Disciplina, "DisciplinaId", "DisciplinaId", estudanteDisciplina.EstudanteId);
            return(View(estudanteDisciplina));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("EstudanteId,DisciplinaId")] EstudanteDisciplina estudanteDisciplina)
        {
            if (ModelState.IsValid)
            {
                _context.Add(estudanteDisciplina);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EstudanteId"] = new SelectList(_context.Disciplina, "DisciplinaId", "DisciplinaId", estudanteDisciplina.EstudanteId);
            return(View(estudanteDisciplina));
        }