private User CreateUserModel(RegisterAsTeacherCommand request)
 {
     return(new User
     {
         UserName = request.TeacherOrStudentNo,
         Email = request.EmailAddress,
         FullName = request.FullName,
         TeacherCode = request.TeacherOrStudentNo
     });
 }
        public async Task <LoginRegisterResponse> Handle(RegisterAsTeacherCommand request,
                                                         CancellationToken cancellationToken)
        {
            if (_userManager.Users.Any(x => x.UserName == request.TeacherOrStudentNo))
            {
                return(UserAlreadyExists());
            }
            if (_userManager.Users.Any(x => x.Email == request.EmailAddress))
            {
                return(EmailAlreadyExists());
            }
            var user = CreateUserModel(request);
            await _userManager.CreateAsync(user, request.Password);

            await _userManager.AddToRoleAsync(user, "Teacher");

            return(await SuccessWithJwtToken(user));
        }