public void RegisterWithExam(StudentToRegister student, int examID) { CreatePasswordHash(student.Password, out byte[] passwordHash, out byte[] passwordSalt); var tempStudent = new Student() { StudentID = student.StudentID, StudentEmail = student.StudentEmail, StudentName = student.StudentName }; tempStudent.StudentPasswordHash = passwordHash; tempStudent.StudentPasswordSalt = passwordSalt; _repository.SecureCreate(tempStudent, examID); }
public IActionResult Register([FromBody] StudentToRegister student) { if (_service.IsUserExist(student.StudentEmail)) { ModelState.AddModelError("UserName", "Username already taken"); } if (!ModelState.IsValid) { return(BadRequest()); } var studentToCreate = new Student() { StudentID = student.StudentID, StudentName = student.StudentName, StudentEmail = student.StudentEmail }; _service.Register(studentToCreate, student.Password); // 201: Created Status return(StatusCode(201)); }