public async Task <IActionResult> Register(UserForRegisterDto userToRegisterDto)
        {
            userToRegisterDto.Email = userToRegisterDto.Email.ToLower();

            if (await _repository.EmailExists(userToRegisterDto.Email))
            {
                return(BadRequest("Email já existe"));
            }

            var userToRegister = new User
            {
                Name  = userToRegisterDto.Name,
                Email = userToRegisterDto.Email,
                Type  = "Normal"
            };

            var registeredUser = await _repository.RegisterUser(
                userToRegister, userToRegisterDto.Password);

            return(StatusCode(201));
        }
        public async Task<IActionResult> Register(RegistrationDataObject regData)
        {
            regData.Username = regData.Username.ToLower();

            if (await _authRepo.UsernameExists(regData.Username))
            {
                return BadRequest("username already exists");
            }

            if (await _authRepo.EmailExists(regData.Email))
            {
                return BadRequest("this email is already taken");
            }

            var userToSave = _mapper.Map<UserModel>(regData);

            var user = await _authRepo.Register(userToSave, regData.Password);

            var userToReturn = _mapper.Map<UserForDetailedViewDataObject>(user);


            return CreatedAtRoute("GetUser", new { Controller = "Users", id = userToReturn.Id }, userToReturn);
        }