Ejemplo n.º 1
0
        public async Task <IActionResult> Create(
            Students students)
        {
            if (ModelState.IsValid)
            {
                var studentsResult = await _servStudents.CreateAsync(students);

                if (studentsResult == null)
                {
                    return(RedirectToAction(nameof(Index)));
                }
            }

            //Log the error (uncomment ex variable name and write a log.
            ModelState.AddModelError("", "Unable to save changes. " +
                                     "Try again, and if the problem persists " +
                                     "see your system administrator.");

            return(View(students));
        }