Example #1
0
        public IActionResult RegistroAlumnos(AlumnoViewModel alumno)
        {
            if (alumno != null)
            {
                string error = ValidarAlumno(alumno);

                if (error != "")
                {
                    ModelState.AddModelError("Error", error);
                    return(View(alumno));
                }

                try
                {
                    AlumnoRepository repos = new AlumnoRepository();
                    repos.InsertAlumno(alumno);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Error", ex.Message);
                    return(View(alumno));
                }
            }

            return(RedirectToAction("Index"));
        }