Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,Name,Class,Science,English,Maths")] StudentModel studentModel)
        {
            if (ModelState.IsValid)
            {
                await _context.Create(studentModel);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(studentModel));
        }
        public ActionResult <Student> RegisterStudent([FromBody] Student student)
        {
            if (StudentValidator.IsUsernameExists(student))
            {
                return(BadRequest(ErrorHandler.GenerateError(999, "Username already exists.")));
            }

            _studentRepo.Create(student);

            return(student);
        }