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! +

+
+
+
+
+
+