Example #1
0
        public IActionResult EditarAlumno(AgregarAlumVM vm)
        {
            rolesrobertoContext context      = new rolesrobertoContext();
            DocenteRepository   docenteRepos = new DocenteRepository(context);
            AlumnosRepository   alumnosRepos = new AlumnosRepository(context);

            try
            {
                var alumno = alumnosRepos.GetById(vm.Alumno.Id);
                if (alumno != null)
                {
                    alumno.Nombre = vm.Alumno.Nombre;
                    alumnosRepos.Edit(alumno);
                    return(RedirectToAction("VAlumno", new { id = alumno.IdDocente }));
                }
                else
                {
                    ModelState.AddModelError("", "El alumno que intentó editar no existe.");
                    vm.Docente     = docenteRepos.GetById(vm.Alumno.IdDocente);
                    vm.lstDocentes = docenteRepos.GetAll();
                    return(View(vm));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                vm.Docente     = docenteRepos.GetById(vm.Alumno.IdDocente);
                vm.lstDocentes = docenteRepos.GetAll();
                return(View(vm));
            }
        }
Example #2
0
        public IActionResult EditarAlumno(int id)
        {
            rolesrobertoContext context      = new rolesrobertoContext();
            DocenteRepository   docenteRepos = new DocenteRepository(context);
            AlumnosRepository   alumnosRepos = new AlumnosRepository(context);
            AgregarAlumVM       vm           = new AgregarAlumVM();

            vm.Alumno      = alumnosRepos.GetById(id);
            vm.lstDocentes = docenteRepos.GetAll();
            if (vm.Alumno != null)
            {
                vm.Docente = docenteRepos.GetById(vm.Alumno.Id);
                if (User.IsInRole("Docente"))
                {
                    vm.Docente = docenteRepos.GetById(vm.Alumno.IdDocente);
                    if (User.Claims.FirstOrDefault(x => x.Type == "Clave").Value == vm.Docente.Clave.ToString())
                    {
                        return(View(vm));
                    }
                }
                return(View(vm));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Example #3
0
        public IActionResult AgregarAlumno(AgregarAlumVM vm)
        {
            rolesrobertoContext context      = new rolesrobertoContext();
            DocenteRepository   docenteRepos = new DocenteRepository(context);
            AlumnosRepository   alumnosRepos = new AlumnosRepository(context);

            try
            {
                if (context.Alumno.Any(x => x.NumeroDeControl == vm.Alumno.NumeroDeControl))
                {
                    ModelState.AddModelError("", "Este número de control ya se encuentra registrado.");
                    return(View(vm));
                }
                else
                {
                    var maestro = docenteRepos.GetDocenteByClave(vm.Docente.Clave).Id;
                    vm.Alumno.IdDocente = maestro;
                    alumnosRepos.Insert(vm.Alumno);
                    return(RedirectToAction("VAlumno", new { id = maestro }));
                }
            }
            catch (Exception ex)
            {
                vm.Docente     = docenteRepos.GetById(vm.Docente.Id);
                vm.lstDocentes = docenteRepos.GetAll();
                ModelState.AddModelError("", ex.Message);
                return(View(vm));
            }
        }
Example #4
0
        public IActionResult VDocente()
        {
            rolesrobertoContext context   = new rolesrobertoContext();
            DocenteRepository   dnteRepos = new DocenteRepository(context);
            var docent = dnteRepos.GetAll();

            return(View(docent));
        }
        public IActionResult VerDocente()
        {
            RolesUsuarioContext context   = new RolesUsuarioContext();
            DocenteRepository   dnteRepos = new DocenteRepository(context);
            var docent = dnteRepos.GetAll();

            return(View(docent));
        }