public HttpResponseMessage Post(UserRegistrationDTO user) { UsersModel userModel = new UsersModel(); bool add = userModel.AddUser(user); HttpResponseMessage response; if (add) { SuccessMessage msg = new SuccessMessage("Registration successful!"); response = Request.CreateResponse(HttpStatusCode.OK, msg); return response; } else { ErrorMessage msg = new ErrorMessage("Registration failed! Username or email already exists"); response = Request.CreateResponse(HttpStatusCode.Forbidden, msg); return response; } }
public void AddUser(UserRegistrationDTO userDTO) { //adauga un user User user = new User() { Username = userDTO.Username, Password = userDTO.Password, Email = userDTO.Email, Role = "user" }; _dataAccess.UserRepository.Add(user); }