public ActionResult CreateUser(UsersForCreation userDto) { var user = _mapper.Map <SovaDataAccessLayer.FrameworkTables.User>(userDto); _dataService.CreateUser(user); return(CreatedAtRoute( nameof(GetUser), new { userId = user.Id }, CreateuserDto(user))); }
public async Task <IActionResult> RegisterUser(UsersForCreation usersForCreation) { usersForCreation.Username = usersForCreation.Username.ToLower(); var checkUserExistTask = _repo.UserExists(usersForCreation.Username); var user = _mapper.Map <User>(usersForCreation); if (await checkUserExistTask) { return(BadRequest("User name already exists")); } var registerTask = _repo.Register(user, usersForCreation.Password); if (registerTask != null) { var userToReturn = _mapper.Map <UsersForReturn>(user); return(CreatedAtRoute("GetUser", new { controller = "users", id = user.Id }, userToReturn)); } return(BadRequest("User registration failed")); }