public async Task Create([FromBody] Students students) { if (ModelState.IsValid) { await _iStudent.AddStudent(students); } }
public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { UserData user = new UserData { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email }; AuthResult result = _authentication.Register(user, model.Password, model.Role); if (result.Succeded) { _logger.LogInformation("User created a new account with password."); string code = _authentication.GenerateEmailConfirmationToken(user); var callbackUrl = Url.EmailConfirmationLink(_authentication.GetUserByEmail(user.Email).Id, code, Request.Scheme); await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl); if (model.Role == "Professor") { Professor professor = new Professor { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email }; _professorServices.AddProfessor(professor); } if (model.Role == "Student") { Student student = new Student { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email }; _studentServices.AddStudent(student); } _logger.LogInformation("User created a new account with password."); return(RedirectToLocal(returnUrl)); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await _auth.RegisterProcess(user, model.Password); if (result) { if (model.Teacher) { _teacherServices.AddTeacher(user); await _auth.SetUserRole(user, "Teacher"); } else { _studentServices.AddStudent(user); await _auth.SetUserRole(user, "Student"); } _logger.LogInformation("User created a new account with password."); return(RedirectToAction("Index", "Home")); } else { ErrorMessage = $"the password does not meet the password policy requirements."; var policyRequirements = $"* At least an uppercase and a special character"; ViewBag.Error = ErrorMessage; ViewBag.policyRequirments = policyRequirements; return(View()); } } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult <Student> AddStudent(Student student) { _service.AddStudent(student); return(student); }
public IHttpActionResult AddStudent([FromBody] StudentViewModel m) { var result = _studentservices.AddStudent(m); return(Ok(result)); }
public void Post([FromBody] StudentDTO student) { _studentServices.AddStudent(student); }