Beispiel #1
0
        public async Task <IActionResult> Register([FromBody] userForRegisterDto userdto)
        {
            if (!string.IsNullOrEmpty(userdto.username))
            {
                userdto.username = userdto.username.ToLower();
            }
            if (await _repo.UserExists(userdto.username))
            {
                ModelState.AddModelError("Username", "Username already exist");
            }
            //Validate request
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var userToCreate = new User
            {
                UserName = userdto.username
            };

            var createUser = await _repo.Register(userToCreate, userdto.password);

            return(StatusCode(201));
            //return CreatedAtRoute();
        }
        public async Task <IActionResult> Register(userForRegisterDto userForRegisterDto)
        {
            userForRegisterDto.Username = userForRegisterDto.Username.ToLower();
            if (await _repo.UserExists(userForRegisterDto.Username))
            {
                return(BadRequest("el nombre de usario ya existe"));
            }
            var userToCreate = new User {
                Username = userForRegisterDto.Username
            };
            var createdUser = await _repo.Register(userToCreate, userForRegisterDto.Password);

            return(StatusCode(201));
        }
Beispiel #3
0
        public async Task <IActionResult> Register(userForRegisterDto userdto)
        {
            userdto.username = userdto.username.ToLower();
            if (await _repo.UserExists(userdto.username))
            {
                return(BadRequest("This user is already exists"));
            }

            var user = new User()
            {
                Name = userdto.username
            };

            var CreatedUser = await _repo.Register(user, userdto.password);

            return(StatusCode(201));
        }
Beispiel #4
0
        public async Task <IActionResult> Register(userForRegisterDto userForRegisterDto)
        {
            // validate request
            userForRegisterDto.Username = Username.ToLower();
            userForRegisterDto.Password = Password;
            if (await _repo.UserExists(userForRegisterDto.Username))
            {
                return(BadRequest("Username already exists"));
            }

            //ggg
            var userToCreate = new User {
                Username = userForRegisterDto.Username
            };

            var createdUser = await _repo.Register(userToCreate, userForRegisterDto.Password);

            var userToReturn = _mapper.Map <UserForDetailedDto>(createdUser);

            return(StatusCode(201));
        }
        public async Task <IActionResult> Register(userForRegisterDto _userForRegisterDto)
        {
            _userForRegisterDto.Email = _userForRegisterDto.Email.ToLower();

            if (await _repo.UserExists(_userForRegisterDto.Email))
            {
                return(BadRequest("This email is already associated with other account"));
            }

            var userToCreate = new UserLog()
            {
                UserEmaill   = _userForRegisterDto.Email,
                UserSex      = _userForRegisterDto.Sex,
                UserFullname = _userForRegisterDto.Fullname
            };

            var createdUser = await _repo.Register(userToCreate, _userForRegisterDto.Password);

            new Mailer(_config.GetSection("AppSettings:MailerEmail").Value, _config.GetSection("AppSettings:MailerPassword").Value)
            .sendWelcomeMail(createdUser.UserEmaill);

            return(StatusCode(201)); // have to change this later
        }