コード例 #1
0
        public IActionResult Edit(int id, [Bind("Id,Nome,Sexo,Email,Nascimento")] Aluno aluno)
        {
            if (id != aluno.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update <Aluno>(aluno);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AlunoExiste(aluno.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

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

            return(View(aluno));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Email,Rg")] Aluno aluno)
        {
            if (id != aluno.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(aluno);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AlunoExists(aluno.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(aluno));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nota")] Matricula matricula)
        {
            if (id != matricula.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(matricula);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MatriculaExists(matricula.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(matricula));
        }
コード例 #4
0
 public async Task <IActionResult> Edit(Curso curso)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(curso);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!CursoExists(curso.CursoId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(curso));
 }
コード例 #5
0
 public void update(int id, Aluno aluno)
 {
     context.Update(aluno);
     context.SaveChanges();
 }