diff --git a/src/main/java/de/hsel/itech/db/pojo/Order.java b/src/main/java/de/hsel/itech/db/pojo/Order.java index 5fa6b3f..116cded 100644 --- a/src/main/java/de/hsel/itech/db/pojo/Order.java +++ b/src/main/java/de/hsel/itech/db/pojo/Order.java @@ -6,7 +6,6 @@ import lombok.NonNull; import lombok.RequiredArgsConstructor; import java.sql.Date; -import java.util.ArrayList; import java.util.List; @@ -34,12 +33,14 @@ public class Order { @NonNull private Payment payment; @NonNull private Address address; - public String getItemNames() { - List titles = new ArrayList<>(); - for(OrderItem item : items) { - titles.add(item.getBook().getTitle()); + public String getFormattedPrice() { + String res = ""; + res += price / 100; + res += ","; + if (price % 100 < 10) { + res += "0"; } - - return String.join(", ", titles); + res += price % 100; + return res; } } \ No newline at end of file diff --git a/src/main/java/de/hsel/itech/jsf/CartBean.java b/src/main/java/de/hsel/itech/jsf/CartBean.java index 47d6d65..bfdc511 100644 --- a/src/main/java/de/hsel/itech/jsf/CartBean.java +++ b/src/main/java/de/hsel/itech/jsf/CartBean.java @@ -36,7 +36,7 @@ public class CartBean { } public String add(Book book) { - if (getUser() != null) { + if (getUser() != null && getUser().getId() != 0) { for (ShoppingCartItem item : getItems()) { if (item.getArticle().getId() == book.getId()) { Database.getInstance().shoppingCart().delete(item); @@ -66,11 +66,6 @@ public class CartBean { } } - /* - public void setItems(List list) { - - }*/ - public String buy() { ArrayList orderList = new ArrayList<>(); for (ShoppingCartItem item : getItems()) { @@ -80,7 +75,7 @@ public class CartBean { for (ShoppingCartItem item : getItems()) { Database.getInstance().shoppingCart().delete(item); } - return "index.jsf"; + return "thanks.jsf"; } public int getItemCount() { diff --git a/src/main/webapp/orders.xhtml b/src/main/webapp/orders.xhtml index 792f6df..c269a01 100644 --- a/src/main/webapp/orders.xhtml +++ b/src/main/webapp/orders.xhtml @@ -10,17 +10,43 @@ +
+
-
-
-
- #{order.itemNames} - #{order.payment.type.name} +
+
+
+ + + + +
+
+
+
+
    + +
  • + #{item.book.title} - #{item.book.authorsString} +
  • +
    +
+
+
+

+ #{order.payment.type.name} +

+

+ #{order.formattedPrice} € +

+
+
+
diff --git a/src/main/webapp/template.xhtml b/src/main/webapp/template.xhtml index b7591d1..8051697 100644 --- a/src/main/webapp/template.xhtml +++ b/src/main/webapp/template.xhtml @@ -38,7 +38,9 @@