예제 #1
0
        public async Task <IActionResult> Edit(int?id, [Bind("AlunoId,TurmaId")] AlunoTurma alunoTurma)
        {
            if (id != alunoTurma.AlunoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(alunoTurma);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AlunoTurmaExists(alunoTurma.AlunoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AlunoId"] = new SelectList(_context.Alunos, "Id", "Nome", alunoTurma.AlunoId);
            ViewData["TurmaId"] = new SelectList(_context.Turmas, "Id", "Idioma", alunoTurma.TurmaId);
            return(View(alunoTurma));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Descricao,Idioma,Nivel,Periodo,ProfessorId")] Turma turma)
        {
            if (id != turma.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(turma);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TurmaExists(turma.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProfessorId"] = new SelectList(_context.Professores, "Id", "CPF", turma.ProfessorId);
            return(View(turma));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,CPF,Telefone")] Professor professor)
        {
            if (id != professor.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(professor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProfessorExists(professor.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(professor));
        }