コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("IdDisciplinas,IdProfessor,IdCurso")] TbDisciplinas tbDisciplinas)
        {
            if (id != tbDisciplinas.IdDisciplinas)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tbDisciplinas);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TbDisciplinasExists(tbDisciplinas.IdDisciplinas))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCurso"]     = new SelectList(_context.TbCursos, "IdCursos", "Ementa", tbDisciplinas.IdCurso);
            ViewData["IdProfessor"] = new SelectList(_context.Set <TbProfessor>(), "IdProfessor", "Email", tbDisciplinas.IdProfessor);
            return(View(tbDisciplinas));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("IdDisciplinas,IdProfessor,IdCurso")] TbDisciplinas tbDisciplinas)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tbDisciplinas);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCurso"]     = new SelectList(_context.TbCursos, "IdCursos", "Ementa", tbDisciplinas.IdCurso);
            ViewData["IdProfessor"] = new SelectList(_context.Set <TbProfessor>(), "IdProfessor", "Email", tbDisciplinas.IdProfessor);
            return(View(tbDisciplinas));
        }