示例#1
0
        public IActionResult EliminarAlumno(Alumno a)
        {
            rolesrobertoContext context      = new rolesrobertoContext();
            AlumnosRepository   alumnosRepos = new AlumnosRepository(context);
            var alumno = alumnosRepos.GetById(a.Id);

            if (alumno != null)
            {
                alumnosRepos.Delete(alumno);
            }
            else
            {
                ModelState.AddModelError("", "El alumno que intentó eliminar no existe.");
            }
            return(RedirectToAction("VAlumno", new { id = alumno.IdDocente }));
        }
        public IActionResult EliminarAlumno(Alumno a)
        {
            rolesusuariosContext context    = new rolesusuariosContext();
            AlumnosRepository    repository = new AlumnosRepository(context);
            var alumno = repository.GetById(a.Id);

            if (alumno != null)
            {
                repository.Delete(alumno);
            }
            else
            {
                ModelState.AddModelError("", "El alumno seleccionado no existe.");
            }
            return(RedirectToAction("VerAlumnos", new { id = alumno.IdMaestro }));
        }
示例#3
0
        public IActionResult EliminarAlumno(Alumno a)
        {
            rolesusuarioContext context = new rolesusuarioContext();
            AlumnosRepository   repos   = new AlumnosRepository(context);

            var alumnoEliminar = repos.Get(a.Id);

            if (alumnoEliminar != null)
            {
                repos.Delete(alumnoEliminar);
            }
            else
            {
                ModelState.AddModelError("", "No se encontro el alumno a eliminar");
            }
            return(RedirectToAction("Alumnos", new { id = alumnoEliminar.IdMaestro }));
        }
示例#4
0
        public IActionResult EliminarAlumno(Alumno a)
        {
            AlumnosRepository repos = new AlumnosRepository(context);
            var original            = repos.Get(a.Id);

            if (original != null)
            {
                repos.Delete(original);
            }
            if (User.IsInRole("Maestro"))
            {
                var id = int.Parse(User.Claims.FirstOrDefault(x => x.Type == "IdUsuario").Value);
                return(RedirectToAction("ListaAlumnos", new { id = id }));
            }
            else
            {
                return(RedirectToAction("ListaAlumnos"));
            }
        }