From 0f763413e96ce6dccd72403d8546aa2860743622 Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Wed, 5 Jun 2019 14:05:00 +0200 Subject: [PATCH] +confirmation and thank-you --- src/main/java/de/hsel/itech/jsf/CartBean.java | 21 +++++- src/main/webapp/cart.xhtml | 2 +- src/main/webapp/confirmation.xhtml | 67 +++++++++++++++++++ src/main/webapp/thanks.xhtml | 21 ++++++ 4 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 src/main/webapp/confirmation.xhtml create mode 100644 src/main/webapp/thanks.xhtml diff --git a/src/main/java/de/hsel/itech/jsf/CartBean.java b/src/main/java/de/hsel/itech/jsf/CartBean.java index 342113a..2b4a3d9 100644 --- a/src/main/java/de/hsel/itech/jsf/CartBean.java +++ b/src/main/java/de/hsel/itech/jsf/CartBean.java @@ -2,6 +2,7 @@ package de.hsel.itech.jsf; import de.hsel.itech.db.Database; import de.hsel.itech.db.pojo.Book; +import de.hsel.itech.db.pojo.OrderItem; import de.hsel.itech.db.pojo.ShoppingCartItem; import de.hsel.itech.db.pojo.User; import lombok.Setter; @@ -57,19 +58,37 @@ public class CartBean { } } + /* public void setItems(List list) { + }*/ + + public String buy(){ + ArrayList orderList = new ArrayList<>(); + for(ShoppingCartItem item : getItems()){ + orderList.add(new OrderItem(item.getArticle(),item.getCount())); + } + //Database.getInstance().order().insert(new Order(getUser(),orderList, new Date(234235235),sum(),null,null)); + for(ShoppingCartItem item : getItems()) { + Database.getInstance().shoppingCart().delete(item); + } + return "thanks.jsp"; } public int getItemCount(){ return getItems().size(); } - public String getSum(){ + public long sum(){ int sum = 0; for(ShoppingCartItem item : getItems()){ sum += item.getCount() * item.getArticle().getPrice(); } + return sum; + } + + public String getSum(){ + long sum = sum(); String res = ""; res += sum / 100; res += ","; diff --git a/src/main/webapp/cart.xhtml b/src/main/webapp/cart.xhtml index 30385c7..58d205b 100644 --- a/src/main/webapp/cart.xhtml +++ b/src/main/webapp/cart.xhtml @@ -58,7 +58,7 @@ diff --git a/src/main/webapp/confirmation.xhtml b/src/main/webapp/confirmation.xhtml new file mode 100644 index 0000000..9801818 --- /dev/null +++ b/src/main/webapp/confirmation.xhtml @@ -0,0 +1,67 @@ + + + + + + +
+

Bestellbestätigung

+
+ +
+
+

Addresse:

+ Max Mustermann
+ Musterstraße 42
+ 12345 Musterstadt +
+
+

Konto

+ IBAN: 12345••••••••••••••••••••••••111
+ Inhaber: Max Mustermann
+
+
+ + + + +
+
+ Buchcover +
+
+

#{item.article.title}

+
+
+

#{item.count} x #{item.article.priceString}€

+
+
+
+ + + +
+

Summe: #{cartBean.sum}€

+
+
+ + +
+
+ Abbrechen +
+
+ + Bestätigen + +
+
+ +
+
+
+ diff --git a/src/main/webapp/thanks.xhtml b/src/main/webapp/thanks.xhtml new file mode 100644 index 0000000..d533914 --- /dev/null +++ b/src/main/webapp/thanks.xhtml @@ -0,0 +1,21 @@ + + + + + + +
+
+

+ Vielen Dank für Ihren Einkauf! +

+
+
+
+
+
+