Esempio n. 1
0
 public async Task<IActionResult> Register(UserForRegisterDto userForRegisterDto)
 {
     //if (!ModelState.IsValid)
     //    return BadRequest(ModelState);
     // validate request
     userForRegisterDto.Username = userForRegisterDto.Username.ToLower();
     if (await _repo.UserExist(userForRegisterDto.Username))
         return BadRequest("user name already exist");
     var userToCreate = new User
     {
         Username = userForRegisterDto.Username
     };
     var createdUser = await _repo.Resgister(userToCreate, userForRegisterDto.Password);
     return StatusCode(201);
 }
Esempio n. 2
0
        public async Task <IActionResult> Register(UserForRegisterDto userforregister)
        {
            userforregister.Username = userforregister.Username.ToLower();

            if (await _repo.UserExist(userforregister.Username))
            {
                return(BadRequest("Username already exist"));
            }

            var usertoCreate = new User
            {
                Username = userforregister.Username,
                Created  = DateTime.Now,
                Gender   = userforregister.Gender
            };

            var createduser = await _repo.Register(usertoCreate, userforregister.Password);

            return(StatusCode(201));
        }