public async Task <IActionResult> register(UserForRegisterDto userforrgstr) { userforrgstr.UserName = userforrgstr.UserName.ToLower(); if (await _repo.UserExists(userforrgstr.UserName)) { return(BadRequest("UserName is Already Exsists")); } var UserToCreate = new User { UserName = userforrgstr.UserName }; var createduser = await _repo.Register(UserToCreate, userforrgstr.password); return(StatusCode(201)); }
public async Task <IActionResult> Register(UserForRegisterDto userforregisterdto) { userforregisterdto.Username = userforregisterdto.Username.ToLower(); if (await _repo.UserExists(userforregisterdto.Username)) { return(BadRequest("The User is already Exsists")); } var usertocreate = _mapper.Map <User>(userforregisterdto); var createduser = await _repo.Register(usertocreate, userforregisterdto.Password); var usertoreturn = _mapper.Map <UserForDetaildto>(createduser); return(CreatedAtRoute("GetUser", new { Controller = "Users", id = createduser.Id }, usertoreturn)); }