public async Task <IActionResult> Edit(int id, [Bind("IdEstudiante,Nombre,Apellido,Activo,Carrera")] DatosEstudiante datosEstudiante)
        {
            if (id != datosEstudiante.IdEstudiante)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(datosEstudiante);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DatosEstudianteExists(datosEstudiante.IdEstudiante))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(datosEstudiante));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("EstudianteID,Matricula,Nombre,Genero,Edad")] Estudiante estudiante)
        {
            if (id != estudiante.EstudianteID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(estudiante);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EstudianteExists(estudiante.EstudianteID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(estudiante));
        }
        public async Task <IActionResult> AddOrEdit([Bind("EstudianteID,Matricula,Nombre,Genero,Edad")] Estudiante estudiante)
        {
            if (ModelState.IsValid)
            {
                if (estudiante.EstudianteID == 0)
                {
                    _context.Add(estudiante);
                }
                else
                {
                    _context.Update(estudiante);
                }
                await _context.SaveChangesAsync();

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