Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Small changes for bookings.
Browse files Browse the repository at this point in the history
  • Loading branch information
G3ralt committed Dec 8, 2017
1 parent 0f517d1 commit f21db92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions HolidayHomesClient/src/components/rentRentableContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ export default class RentRentable extends Component {
}
// console.log("JSON:", json);
const options = fetchHelper.makeOptions("POST", true, json);
fetch(URL + "api/booking/create", options).catch(err => {
fetch(URL + "api/booking/create", options)
.then(
window.location.href = this.state.clientOrigin + "/#/myDashboard/myBookings"
)
.catch(err => {
console.log(err);
})
alert("Booking created");
window.location.href = this.state.clientOrigin + "/#/myDashboard/myBookings";

}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void createNewBooking(Booking booking) throws DBException {
public List<Booking> getBookingsByUser(String username) throws DBException {
List<Booking> toReturn;
try {
EM.getEntityManagerFactory().getCache().evictAll();
Query q = EM.createQuery("SELECT b FROM Booking b WHERE b.user.username = :username", Booking.class);
q.setParameter("username", username);
toReturn = q.getResultList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public RentableFacade(EntityManager EM) {
public Rentable getRentableByName(String rentableName, String username) throws DBException {
Rentable toReturn;
try {
EM.getEntityManagerFactory().getCache().evictAll();
Query q = EM.createQuery("SELECT r FROM Rentable r WHERE r.rentableName = :rentableName");
q.setParameter("rentableName", rentableName);
toReturn = (Rentable) q.getSingleResult();
Expand Down

0 comments on commit f21db92

Please sign in to comment.