Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- @Path("CreateUser")
- public Response createUser(@FormParam("firstname") String firstname,@FormParam("lastname") String lastname,@FormParam("email") String email,@FormParam("password") String password,@FormParam("address") String address,@FormParam("birthday") String birthday,@FormParam("registerDate") String registerDate,@FormParam("relationship") String relationship,@FormParam("phoneNumber") String phoneNumber,@FormParam("gender") String gender,@FormParam("interestedIn") String interestedIn){
- Connection conn=GetConnection.getInstance().getConnection();
- User u=new User();
- u.setFirstname(firstname);
- u.setLastname(lastname);
- u.setEmail(email);
- u.setPassword(password);
- u.setAddress(address);
- Date birth=null;
- try {
- birth=new SimpleDateFormat("dd/MM/yyyy").parse(birthday);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- u.setBirthday(birth);
- Date register=null;
- try {
- register=new SimpleDateFormat("dd/MM/yyyy").parse(registerDate);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- u.setRegisterDate(register);
- u.setRelationship(Boolean.parseBoolean(relationship));
- u.setPhoneNumber(Integer.parseInt(phoneNumber));
- u.setGender(Boolean.parseBoolean(gender));
- u.setInterestedIn(Boolean.parseBoolean(interestedIn));
- Boolean test=new DaoUser(conn).create(u);
- Response response=null;
- if(test)
- response=Response.status(Response.Status.OK).entity(true).build();
- else
- response=Response.status(Response.Status.BAD_REQUEST).entity(u).build();
- return response;
- }
Advertisement
Add Comment
Please, Sign In to add comment