public Reservation startReservationManagement(int nextID,Product product, User u) {
System.out.println("next id: " + nextID);
RestClient add_reservationto_server = new RestClient();
if (product instanceof Video){
Reservation reservation = new Reservation(nextID,u,product,new Date(),new Date(),false);
//System.out.println("json: " + encodeJsonObject(reservation).toJSONString());
//System.out.println("json: " + encodeJsonObjectProductstats(reservation).toJSONString());
add_reservationto_server.apacheHttpClientPost(Login.url+"api/reservation/reservation/", reservation.getUser().getUsername(), reservation.getUser().getPassword(), encodeJsonObject(reservation));
add_reservationto_server.apacheHttpClientPatch(Login.url+"api/reservation/product/"+reservation.getProduct().getId()+"/", reservation.getUser().getUsername(), reservation.getUser().getPassword(), encodeJsonObjectProductstats(reservation));
return reservation;
}
else if (product instanceof Book ){
Reservation reservation = new Reservation(nextID,u,product,new Date(),new Date(),false);
//System.out.println(encodeJsonObject(reservation).toJSONString());
add_reservationto_server.apacheHttpClientPost(Login.url+"api/reservation/reservation/", reservation.getUser().getUsername(), reservation.getUser().getPassword(), encodeJsonObject(reservation));
add_reservationto_server.apacheHttpClientPatch(Login.url+"api/reservation/product/"+reservation.getProduct().getId()+"/", reservation.getUser().getUsername(), reservation.getUser().getPassword(), encodeJsonObjectProductstats(reservation));
return reservation;
}
return null;
}