public ActionResult <AuthenticationResponse> Register(RegisterRq registerRq) { if (UserExists(registerRq.username)) { return(BadRequest("Username is taken")); } if (idExists(registerRq.idUser)) { return(BadRequest("IdUser is taken")); } var userReg = new User { Email = registerRq.email, Username = registerRq.username.ToLower(), Parola = registerRq.password, Nume = registerRq.nume, Prenume = registerRq.prenume, IdUser = registerRq.idUser }; _context.Users.Add(userReg); _context.SaveChanges(); return(new AuthenticationResponse { Username = userReg.Username, Id = userReg.IdUser, Token = _tokenService.CreateToken(userReg) }); }
public bool SaveChanges() { return(_context.SaveChanges() > 0); }